在我的应用程序中,所有背景设置为 @background="@android:color/white"
的 View 都可以在除 Samsung Galaxy S3 mini 之外的所有设备上正确显示。在这种情况下,所有这些 View 都设置为灰色背景。
在此特定情况下,包含复选框的 LinearLayout 的背景应为白色:
<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>
我尝试将 android:background="@android:color/white"
替换为 android:background="#FFFFFF"
,但唯一可行的解决方案是在我的 drawable 目录中创建一个 white_bg.xml:
<item android:bottom="0px">
<shape android:shape="rectangle" >
<solid android:color="@android:color/white" />
</shape>
</item>
并将背景设置更改为 android:background="@drawable/white_bg"
。
虽然我认为这可以解决我的问题,但更改我的应用程序中的所有布局非常烦人,尤其是因为这个问题似乎只影响少数设备。我想知道是否有更优雅的解决方案。
最佳答案
更改 AppTheme 中的“windowBackground”:
在“styles.xml”中
<style name="AppTheme" parent="Theme.Holo">
<item name="android:windowBackground">@color/white</item>
</style>
并从您的 LinearLayout 中删除背景属性。
当然要确保您的 Activity 使用 AppTheme 作为主题。 (同时将@color/white 值设置为“#ffffffff”)
关于Android 背景颜色设置为灰色而不是@android :color/white,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25204484/