Change Background color of the action bar using AppCompat

<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background"  tools:ignore="NewApi">@color/red</item>
    <item name="background">@color/red</item>
</style>

<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light">
    <item name="android:actionBarStyle"   tools:ignore="NewApi">@style/MyActionBar</item>
    <item name="actionBarStyle">@style/MyActionBar</item>

</style>

you need both android:background and background items. The former is for newer versions of android that support ActionBar natively. The latter is for older android versions.

EDIT

instead of <resources> use

<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">

From SDK 21

to change Action Bar background color, add this to ActionBarTheme, and the two colours are to be different or it will not work (thanks to @Dre and @lagoman)

<item name="colorPrimary">@color/my_awesome_red</item> 
<item name="colorPrimaryDark">@color/my_awesome_darker_red</item>

Leave a Comment