Android: Background change in styles.xml

故事扮演 提交于 2019-12-04 21:11:56

问题


I'm trying to change the background color to black in styles.xml. The background changes fine but the actionbar got dirty. Some part of the actiobar background stays the same while the other portion turns black. I don't want the actionbar to change color. Please help

<style name="Theme.ApplicationTheme" parent="@style/Theme.Sherlock">
    <item name="android:background">#000000</item> <!-- This line is changing the actionbar color -->
    <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
</style>

<style name="Widget.MyApplicationTheme.ActionBar" parent="Widget.Sherlock.ActionBar">
    <item name="android:background">#2d2d2d</item>
    <item name="background">#2d2d2d</item>
</style>

回答1:


Add following two additional items:

    <item name="android:windowBackground">#000000</item>
    <item name="android:colorBackground">#000000</item>

So that your style would look like:

<style name="Theme.ApplicationTheme" parent="@style/Theme.Sherlock">
    <item name="android:background">#000000</item> <!-- This line is changing the actionbar color -->
    <item name="android:windowBackground">#000000</item>
    <item name="android:colorBackground">#000000</item>
    <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
</style>


来源:https://stackoverflow.com/questions/16901934/android-background-change-in-styles-xml

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