简体   繁体   English

Android - 灰色背景而不是白色

[英]Android - gray background instead of white

Each "layout" I set a white background and "Manifest" I set Theme.Light.每个“布局”我都设置了白色背景,“清单”我设置了 Theme.Light。 Still receives a gray background instead of white.仍然收到灰色背景而不是白色。 Why?为什么?

Edit:编辑:

Manifest.xml清单文件

android:theme="@android:style/Theme.Light.NoTitleBar">

Layout布局

android:background="@android:color/white" 

Theme.Light does not mean that it will be white. Theme.Light 并不意味着它会是白色的。 It just means that it will be light, not dark :P This is not theme.white.这只是意味着它将是浅色,而不是深色:P 这不是 theme.white。

Each device manufacturer can customize Android OS on his phone for example to preferred colors and look & feel.每个设备制造商都可以在他的手机上自定义 Android 操作系统,例如自定义首选颜色和外观。 In particular he can define styles for his Android implementation - Light and dark.特别是他可以为他的 Android 实现定义样式 - 浅色和深色。 Thanks to that your app may look differently on various devices, however it will always fit the style used on this device (every app in style Theme.Light will have grey background on this device, unless you set android:background="@android:color/white" )多亏了这一点,您的应用程序在各种设备上的外观可能会有所不同,但它始终适合此设备上使用的样式(Theme.Light 样式中的每个应用程序在此设备上都将具有灰色背景,除非您设置 android:background="@android:白颜色” )

Your device's manufacturer defined style Theme.Light as style with grey background.您的设备制造商将样式 Theme.Light 定义为带有灰色背景的样式。

Hope that I am clear - otherwise do not hesitate to ask希望我清楚 - 否则不要犹豫问

I had the same issue until I changed @android:color/white to explicit android:background="#FFFFFF" .我遇到了同样的问题,直到我将@android:color/white更改为显式android:background="#FFFFFF" Weird though...虽然很奇怪...

Since it's an old question this might have another solution already but anyway one can just enter the AppTheme style tag in styles.xml, you can do so by pressing the ⌘cmd key and clicking on your theme declaration in the manifest.由于这是一个老问题,因此可能已经有另一个解决方案,但无论如何都可以在 style.xml 中输入 AppTheme 样式标记,您可以通过按 ⌘cmd 键并单击清单中的主题声明来实现。

Over there add this line with your preferred color -在那里用你喜欢的颜色添加这条线 -

<item name="android:windowBackground">@color/white</item>

This line basically overrides the theme's default background value.这一行基本上覆盖了主题的默认背景值。

Example -例子 -

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:colorControlActivated">@color/black</item>
    <item name="android:windowBackground">@color/white</item>
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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