【问题标题】:Changing the background color affects children更改背景颜色会影响儿童
【发布时间】:2014-03-25 14:52:33
【问题描述】:

我试图通过在主应用程序主题中添加一行来更改应用程序的基本背景颜色:

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:background">@android:color/white</item>
</style>

但是它会级联到像这样的操作栏和徽标这样的子对象:

我做错了什么?

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    使用android:windowBackground 代替background 属性:

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

    【讨论】:

    • 完美,感谢您的帮助。你能解释一下为什么我的原始代码会这样级联吗?即使没有明确命名,有没有办法继承父级的背景颜色?
    • 不确定,但我认为您的行为 background 为所有视图提供了背景颜色,而 windowBackground 仅适用于背景窗口,请参阅此答案:stackoverflow.com/a/16239788/2668136
    猜你喜欢
    • 1970-01-01
    • 2019-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    相关资源
    最近更新 更多