Search code examples
androidandroid-layoutandroid-stylesandroid-actionbar-compat

Android Action bar won't obey background color


I've just updated my project to target API 22, and my action bar style appears to have broken. Despite setting the background to white, and the color to blue, I end up with a black action bar with white text.

Here's my application theme.

<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:homeAsUpIndicator">@drawable/up_button</item>
    <item name="android:actionMenuTextAppearance">@style/H4.Other</item>
    <item name="android:actionMenuTextColor">@color/h4_other</item>
    <item name="android:windowContentOverlay">@drawable/header_shadow</item>
    <item name="android:buttonStyle">@style/ButtonStyle.NoCaps</item>
</style>

Here's my action bar style.

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:title">""</item>
    <item name="android:background">@color/white</item>
    <item name="android:height">@dimen/action_bar_height</item>
    <item name="android:titleTextStyle">@style/H5.Blue</item>
</style>

Solution

  • Ok I figured this out. When you've updated the version of the app compat library you're using, the namespacing of some attributes needs to change. In my case it was changing from android:background to just background, among other things.