设置 Android 主题背景色 [英] Setting Android Theme background color

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

问题描述

我正在尝试修改默认的背景主题颜色,这应该很容易,但令人惊讶的是我无法让它工作.请注意,我希望对整个应用程序进行更改,而不仅仅是针对单个活动.这是我的代码:

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>

当然在清单中

<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

我已经尝试在所有 xml 属性的 white_opaque 和 pitch_black 之间切换,但它没有改变任何事情.有什么建议吗?

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.

我正在编辑的 style.xml 文件位于默认值文件夹中.我编辑了 values-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 主题背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆