My action bar title is taking the wrong color from

2019-08-02 03:30发布

I'm attempting to modify the theme for my application. I've been able to successfully set the background color for my app, and the background color for my action bar.

Unfortunately, the background color of the items WITHIN the action bar are taking the background color of the app, not the bg color of the action bar.

Here's my code from styles.xml

<!--
    Base application theme for API 11+. This theme completely replaces
    AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>


<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:background">#ff0000</item>
</style>


<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">#fefefe</item>
</style>

and here's a screenshot of what's happening.

screenshot of weird bg colors

Hoping I'm missing something stupid here...

Thanks!

2条回答
一夜七次
2楼-- · 2019-08-02 03:45

I'm pretty sure your theme background is being applied to everything. Instead, you only want the activity's background to be that color. So instead of setting the background color in the theme, you should set it for the activity. If you have many activities that will use this background color, then create a style for your activities and apply it to each one.

查看更多
手持菜刀,她持情操
3楼-- · 2019-08-02 03:45

Try using:

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

Worked for me.

查看更多
登录 后发表回答