Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android background color set to gray instead of @android:color/white

In my app all the views whose background is set to @background="@android:color/white" are showed properly on all the devices apart from Samsung Galaxy S3 mini. In this case all these views have a gray background set.

enter image description here

In this specific case the background of the LinearLayout containing the checkboxes should be white:

<LinearLayout
                android:id="@+id/ll_child1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/white"
                android:padding="10dp"
                android:orientation="vertical" >
...
</LinearLayout>

I tried to replace android:background="@android:color/white" with android:background="#FFFFFF", but the only working solution has be the one of creating a white_bg.xml into my drawable directory:

<item android:bottom="0px">
    <shape android:shape="rectangle" >
        <solid android:color="@android:color/white" />
    </shape>
</item>

and changing the background setting to android:background="@drawable/white_bg".

Thought this solves my problem, changing all the layouts in my app is quite annoying, especially because this problem seems to affect in few devices only. I wonder if there's a more elegant solution to this.

like image 709
ecostanzi Avatar asked Aug 08 '14 13:08

ecostanzi


People also ask

How do I make my background White on Android?

Use either the Auto or manual mode to remove the background. Tap on the next icon at the top. Tap on Color tab at the bottom. Using sliders, select the color white.

What is the default background color in Android?

By default each activity in Android has a white background. To change the background color, first add a new color definition to the colors.

How do I change the background color in view?

Android App Development for Beginners This example demonstrates about How do I change the color of Button in Android when clicked. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.


1 Answers

Change the "windowBackground" in AppTheme:

In "styles.xml"

<style name="AppTheme" parent="Theme.Holo">
    <item name="android:windowBackground">@color/white</item>
</style>

And remove background attribute from your LinearLayout.

Of course make sure your activity using AppTheme as it's theme. (also set @color/white value to "#ffffffff")

like image 52
semsamot Avatar answered Oct 29 '22 19:10

semsamot