How to change title and Subtitle text color and size of ActionBar in Android?

By | October 9, 2014

Here is a simple example that shows how you can change title and subtitle textcolor and its size in Android

Method 1

Changing the styles [For support Library]

Go to Values/styles.xml copy this code to change the textcolor and actionbar background color.

<style name="CustomActivityTheme" parent="@style/Theme.AppCompat.Light">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="actionBarStyle">@style/MyActionBar</item>
         <item name="android:windowActionBarOverlay">true</item>
        <!-- other activity and action bar styles here -->
      <!-- style for the action bar backgrounds -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
        <item name="android:background">@drawable/actionbar_background</item>
        <item name="background">@drawable/actionbar_background</item>
        <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
        <item name="android:subtitleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
        <item name="titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
        <item name="subtitleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance">
        <item name="android:textColor">@color/color_title</item>
        <item name="android:textSize">12sp</item>

Note : For applying theme if you are not using the Support Library then change the AppCompat to Holo.

i.e make the Below changes in the parent




AND for title


Now Apply this theme in the AndroidManifest.xml, either for the entire application or a particular activity.

For example

        android:theme="@style/CustomActivityTheme" >
            android:label="@string/app_name" >
                <action android:name="android.intent.action.MAIN" />

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

Make Sure you add the colors in the strings.xml

<?xml version="1.0" encoding="utf-8"?>

    <string name="app_name">ActionBarCustomize</string>
    <string name="hello_world">Hello world!</string>
    <string name="menu_settings">Settings</string>

    <drawable name="actionbar_background">#FF0000</drawable>
    <color name="color_title">#00FF00</color>

Method 2

You can use a simple java code to so this.

getActionBar().setTitle(Html.fromHtml("<font color='#ff0000'>ActionBartitle </font>"));

Note : Change getActionBar() to getSupportActionBar() if you are using the support library for ActionBar.

That’s all.. Now Run the application and see the changes.

2 thoughts on “How to change title and Subtitle text color and size of ActionBar in Android?

  1. Aleksandr Strizhevskiy

    Dude!!! It is 6AM and I have been up a all night trying to get my code to work. Ive been searching for like 2 hours alone just for the title text. All the official examples are from before AppCompacActivity. Or maybe Im just dumb.

    Either way your code worked and I am super grateful!


Leave a Reply

Your email address will not be published. Required fields are marked *