如何在自定义主题Android中更改colorBackground?

时间:2015-10-17 05:30:30

标签: android background themes

我想通过主题在我的整个应用程序中更改backgroundColor。这是我的努力,虽然不成功:

RES /值/ styles.xml

<resources>

<color name="bgColor">#FFFFFF</color>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:colorBackground">@color/bgColor</item>
    <item name="android:windowBackground">@color/bgColor</item>
</style>
</resources>

的Manifest.xml

 <application
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

我在Android 4.4和5.0上试过这个。我究竟做错了什么?有什么建议吗?

2 个答案:

答案 0 :(得分:1)

好的,事实证明我犯了一个非常愚蠢的错误。我用于测试的设备运行的是Android 4.0.4,API级别15。 我正在编辑的styles.xml文件位于默认值文件夹中。我在values-v14文件夹中编辑了styles.xml,现在一切正常。

这是Stark的帖子,他向你指出了类似的问题,他找到了解决方案。您可以找到更多详细信息here

答案 1 :(得分:1)

嘿,你更新android studio到1.4它有内置的主题编辑器,你可以在下面的图片中看到。

enter image description here