Styling Sherlock actionbar – Change actionbar color

Just few step to change the style of Sherlock actionbar. Here it goes like this

1)make your application theme something like shown below

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

    <style name="MyCustomTheme" parent="Theme.Sherlock">
     <-- This one is for below android 3.x device-->
     <item name="actionBarStyle">@style/ActionBar</item>
     <-- This one is for android 3.x or greater device-->
     <item name="android:actionBarStyle">@style/ActionBar</item>


2) Define style for action bar

 <!-- style for actionbar(Equivalent to titlebar) -->
    <style name="ActionBar" parent="Widget.Sherlock.ActionBar">
        <item name="background">@drawable/actionbar_bg_top</item> -----------(1)
        <item name="android:background">@drawable/actionbar_bg_top</item>
        <item name="android:titleTextStyle">@style/customTextAppearance.Sherlock.Widget.ActionBar.Title</item> ----(2)
        <item name="titleTextStyle">@style/customTextAppearance.Sherlock.Widget.ActionBar.Title</item>
<!-- define text style of Action bar Title -->
 <style name="customTextAppearance.Sherlock.Widget.ActionBar.Title" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
        <item name="android:textSize">14dp</item>
        <item name="android:textColor">#083647</item>
        <item name="android:shadowColor">#4ccfff</item>
        <item name="android:shadowDy">3</item>

equation 1–> define the background color of action bar. @drawable/actionbar_bg_top may be in the form of nine patch image or color
equation 2 –>define the style of Text that appear as title in Sherlock actionbar

3)Use the theme on application in android manifest file

        android:theme="@style/MyCustomTheme" >
            android:label="app" >
                <action android:name="android.intent.action.MAIN" />

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

That’s all for changing color of actionbar in Sherlock action bar
here is the affect

Enjoy android styling 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s