本文介绍了设置Android的主题背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想修改默认的背景主题色,这应该是容易的,但令人惊讶的,我不能得到它的工作。请注意,我要的改变是整个应用程序,而不仅仅是一个单一的活动。这是我的code:

I'm trying to modify the default background theme color, which should be easy but surprisingly I can't get it working. Please note that I want the change to be across the entire app, not just for a single activity. Here is my code:

styles.xml

styles.xml

<resources>

<color name="white_opaque">#FFFFFFFF</color>
<color name="pitch_black">#FF000000</color>

    <style name="AppTheme" parent="android:Theme.Light">
      <item name="android:background">@color/white_opaque</item>
      <item name="android:windowBackground">@color/white_opaque</item>
      <item name="android:colorBackground">@color/white_opaque</item>

    </style>
</resources>

和课程清单中的

  <application
     .
     .
     .
        android:theme="@style/AppTheme" >
</application>

Android的文档,我咨询了修改主题:http://developer.android.com/guide/topics/ui/themes.html

Android doc which I consulted on modifying themes:http://developer.android.com/guide/topics/ui/themes.html

我已经试过white_opaque和pitch_black之间切换的所有XML属性,但它不会改变任何事情。有什么建议?

I've tried switching between white_opaque and pitch_black for all the xml attributes but it doesn't change a thing. Any suggestions?

推荐答案

好吧原来,我做了一个非常愚蠢的错误。我使用的测试设备运行的是Android 4.0.4,API级别15。

Okay turned out that I made a really silly mistake. The device I am using for testing is running Android 4.0.4, API level 15.

这是我在编的styles.xml文件在默认值的文件夹。我编辑的价值观V14文件夹中的styles.xml,它工作一切优秀了。

The styles.xml file that I was editing is in the default values folder. I edited the styles.xml in values-v14 folder and it works all fine now.

这篇关于设置Android的主题背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 18:03