Setting Android Theme background color

為{幸葍}努か 提交于 2019-11-27 01:25:55

问题


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

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

and of course in the manifest

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

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

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


回答1:


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.

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.




回答2:


<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Holo.NoActionBar">
        <item name="android:windowBackground">@android:color/black</item>
    </style>

</resources>


来源:https://stackoverflow.com/questions/11779679/setting-android-theme-background-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!