0
votes

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>
2
what is your emulator android version? if it's lower than 21 try using <item name="background">@color/white</item>Amir
@tufan, are you sure? If I want to be using the appcompat version of material themes, I thought you don't want any of the attributes in v14?Zach Sperske
Check My Answer...it will help youTufan
Amir was right, using the attribute without the android: namespace fixed the issue.Zach Sperske

2 Answers

0
votes

When supporting Android 3.0 and higher only, you can define the action bar's background like this:

res/values/themes.xml

<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
       parent="@android:style/Theme.Holo.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar"
       parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@color/white</item>
</style>
</resources>

Then apply your theme to your entire app or individual activities:

<application android:theme="@style/CustomActionBarTheme" ... />

Read Android Documentation

0
votes

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.