Android Custom ActionBar Style Example

Although ActionBar provides users with a globally unified interface style and operation, it doesn’t mean that all applications’ ActionBars have to be exactly the same. If you need to modify the style of your ActionBar to better match your application, you can make it very simple by using Android styles and themes.

Several of Android’s built-in Activity themes already contain ActionBar styles such as “dark” or “light”, and you can also inherit these themes and make further customization.

1. Use Theme To Change Action Bar Style.

Below basic Activity themes in Android can be used to specify the color of the ActionBar, they are:

  1. @android:style/Theme.Holo : This is a dark-colored theme.
    action bar theme holo
  2. @android:style/Theme.Holo.Light : This is a light-colored theme.
    action bar theme holo light
  3. @android:style/Theme.Holo.Light.DarkActionBar : The ActionBar will be dark-colored, the content view bill be light-colored.
    action bar theme holo light dark action bar

You can apply these themes to your entire application, or you can apply it to just one Activity.

Specify android:theme properties for the <application> or <activity> tags in AndroidManifest.xml file. For example:


<activity android:name=".ActionBarCustomStyleActivity"
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />

Please Note :  The Activity class must extends, it can not extends or it’s sub class, otherwise you will meet below error when execute the application.

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

android activity appcompat theme error

You can use below java code to set theme.


2. Custom ActionBar Background.

If you want to modify the background of your ActionBar, you can implement it by creating a custom theme and rewriting the actionBarStyle property.

This property can point to another style, and then override background in that style to specify a drawable resource or color to implement the functionality of the custom background.

  1. Edit app / res / values / styles.xml file.
    <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/NewActionBar</item>
    <style name="NewActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">#00ff00</item>
  2. Use the custom theme as application or activity’s android:theme property value.
    <activity android:name=".ActionBarCustomStyleActivity"
        android:theme="@style/CustomActionBarTheme" >

    custom action bar background color

0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x