Behavior of Actionbar can also be changed in APIs < 11
See the Android Official Documentation for reference
I am building an app with minSdkVersion = "9"
and targetSdkVersion = "21"
I changed the color of action bar and it works fine with API level 9
Here is an xml
res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/actionbar_background</item>
<!-- Support library compatibility -->
<item name="background">@color/actionbar_background</item>
</style>
</resources>
and set the color of actionbar you want
res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="actionbar_background">#fff</color> //write the color you want here
</resources>
Actionbar color can also be defined in .class
file, the snippet is
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0000ff")));
but this will not work with the API < 11, so styling the actionbar in xml
is only way for API < 11