简体   繁体   中英

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.

在此输入图像描述

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.

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM