Quick Android Tips: Changing ActionBarSherlock Title Color and Size

December 16, 2012

If you are using ActionBarSherlock, and want to quickly change the color, and size of the title, you need to fiddle a bit with a style resource. Here is what you need to do:

Create a resource file styles_mytheme.xml under res/values folder and copy the following. (Note: If you already have your theme styles defined earlier, perhaps using the Android Action Bar Style Generator, just match the style elements based on the parent=“xxx”, and add the missing item elements.)

[frameworkads ad=“1”]

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

<resources>
    <style name="MyTheme" parent="@style/Theme.Sherlock">
        <item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>
    </style>

    <style name="MyTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar">
        <item name="android:titleTextStyle">@style/MyTheme.TitleTextStyle</item>
    </style>

    <style name="MyTheme.TitleTextStyle" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Title">
        <item name="android:textColor">#CC0000</item>
        <item name="android:textSize">20sp</item>
    </style>

</resources>

Now, you need to use MyTheme instead of using a SherlockTheme. Basically, in your AndroidManifest.xml file, you need to have something like:

<application
        android:label="@string/app_name"
        android:theme="@style/Theme.tagsnap">

    ...
    ...
    ...
</application>

Discussion, links, and tweets

By day, I ship code at MetaGeek, by night, I hack on my personal projects, and finally, when I get some off time in between, I also serve as a CTO for ClockworkEngine, LLC where so far we have launched two products - Spyglass and LightPaper. Call be a serial coder if you want.