There are two ways to change the background of the tab bar:
1) If you use tabs only in portrait orientation, you can set the backgroundStacked (and android:backgroundStacked ) element (android:)actionBarStyle . It sets the background for a complex action bar (tab bar).
Your topic should contain:
<style name="Theme.MyTheme" parent="Theme.Sherlock.Light.DarkActionBar"> <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item> <item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item> </style>
Then the ActionBarStyle should be:
<style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar"> <item name="android:background">#ff0000ff</item> <item name="background">#ff0000ff</item> <item name="android:backgroundStacked">#ffff</item> <item name="backgroundStacked">#ffff</item> </style>
That is all you need. But this solution will not work in the landscape. In the landscape, tabs can be moved to the main action bar.
2) If you use tabs in both portrait and landscape orientation, you must use a different solution.
The topic should contain:
<style name="Theme.MyTheme" parent="Theme.Sherlock.ForceOverflow"> <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item> <item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item> <item name="actionBarTabBarStyle">@style/Widget.MyTheme.TabBar</item> <item name="android:actionBarTabBarStyle">@style/Widget.MyTheme.TabBar</item> </style>
And set the background for the style of the tab bar:
<style name="Widget.MyTheme.TabBar" parent="Widget.Sherlock.ActionBar.TabBar"> <item name="android:background">#ffff</item> </style>
Note If you try to combine both approaches, then the background from actionBarTabBarStyle will be placed on top of the background from backgroundStacked .
Note These two approaches set the background for the entire tab bar; the background setting for one tab in the tab bar is different.
Tab text color
If you want to set the text color for tabs, you must define actionBarTabTextStyle .
The topic should contain:
<style name="Theme.MyTheme" parent="Theme.Sherlock.Light.DarkActionBar"> ... <item name="actionBarTabTextStyle">@style/MyTheme.ActionBar.TabText</item> <item name="android:actionBarTabTextStyle">@style/MyTheme.ActionBar.TabText</item> </style>
Tab Text Style:
<style name="MyTheme.ActionBar.TabText" parent="Widget.Sherlock.ActionBar.TabText" > <item name="android:textColor">#FF000000</item> </style>