Android Styling ActionBar Title And SubTitle

By | April 16, 2015

In the previous tutorial we have seen how to custom android actionbar by changing the default background with custom background in this tutorial we will see how to customize the actionbar title and subtitle  with text color , text size , text style .

In Code

The ActionBar title ID is hidden, or in other words, it’s internal and accessing it can’t be done typically. You can reference it using Resources.getIdentifier then View.findViewById though. Grab the ID for the action_bar_title

int titleId = getResources().getIdentifier(“action_bar_title”, “id”, “android”);

Now you can use the ID with a TextView

TextView abTitle = (TextView) findViewById(titleId);


Declare set of color constants inside the res/values/colors.xml

file : res/values/colors.xml

<?xml version=”1.0″ encoding=”utf-8″?>
     <color name=”Red”>#FF0000</color>
     <color name=”Green”>#008000</color>
     <color name=”Blue”>#0000FF</color>
     <color name=”LightGreen”>#98BD49</color>
     <color name=”Orange”>#FA8400</color>
     <color name=”Pink”>#F50057</color>
     <color name=”Yellow”>#FFF0F0</color>
     <color name=”Black”>#000000</color>
     <color name=”White”>#FFFFFF</color>

Adding the below style inside the res/values/style.xml , res/values-v11/style.xml , res/values-v14/style.xml

<resources xmlns:android=””>

    <!– Application theme. –>
    <style name=”AppTheme” parent=”@android:style/Theme.Holo.Light.DarkActionBar”>
        <item name=”android:actionBarStyle”>@style/MyActionBar</item>

    <!– ActionBar styles –>
    <style name=”MyActionBar” parent=”@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse”>
        <item name=”android:background”>@color/Pink</item>
        <item name=”android:titleTextStyle”>@style/MyActionBarTitleText</item>
        <item name=”android:subtitleTextStyle”>@style/MyActionBarSubTitleText</item>

    <!– ActionBar title text –>
    <style name=”MyActionBarTitleText” parent=”@android:style/TextAppearance.Holo.Widget.ActionBar.Title.Inverse”>
        <item name=”android:textColor”>@color/White</item>
        <item name=”android:textStyle”>bold</item>

    <!– ActionBar subtitle text –>
    <style name=”MyActionBarSubTitleText” parent=”@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle”>
        <item name=”android:textColor”>@color/White</item>
        <item name=”android:textStyle”>bold</item>


Inside manifest file for application tag set the theme property with above defined style name