0

So I'm trying to style my tabs of my ActionBar, that I've implemented using the ActionbarSherlock library. I've managed to style the bar with the icons itself, but not the tabs below it. Does anybody have any idea what is preventing me from doing this? This is my code:

<?xml version="1.0" encoding="utf-8"?>
  <resources>
    <style name="CustomStyleTostrams" parent="Theme.Sherlock.Light">
            <item name="actionBarTabStyle">@style/customActionBarStyle</item>
            <item name="android:actionBarTabStyle">@style/customActionBarStyle</item>
        </style>

        <style name="customActionBarStyle" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
            <item name="background">@drawable/bg_tabs_image</item>
            <item name="android:background">@drawable/bg_tabs_image</item>
        </style>
  </resources>

UPDATE: So I figured something out. I'm using the standard TabManager (implementing TabHost.OnTabChangedListener) with a TabWidget, which for some reason does not work with the normal styling. I tested my code above by copying the "ABS: Styled" sample. However, I don't know how I would implement onTabSelected and onTabUnSelected for example. What is the best way to do this? Using the ABS: Styled sample, or to try and style TabWidget in a different way?

Hidde
  • 374
  • 5
  • 16

2 Answers2

2

I did this by creating the following styles: Note that tab_indicator_ab_holo is my custom nine-patch

<style name="SearchTabView"  parent="Widget.Sherlock.ActionBar.TabView">
    <item name="android:background">@drawable/tab_indicator_ab_holo</item>
</style>

<style name="SearchTheme" parent="Theme.Sherlock.Light.DarkActionBar">
    <item name="actionBarTabStyle">@style/SearchTabView</item>
    <item name="android:actionBarTabStyle">@style/SearchTabView</item>
</style>
1

In fragments_tabs_pager.xml (if thats the one you're using). Just set the background of the tabwidget: TabWidget android:id="@android:id/tabs" android:orientation="horizontal" android:background="#F0F0F0" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0"

As to the question of styling selectors, diveders etc..I don't know yet, I think Im confusing tab bar with tabs that you can have inside the action bar itself. The tabs inside the actionbar are the only ones I've found good answers for. So please answer that one as well if you can Jake :)

Karl
  • 332
  • 2
  • 10
  • 1
    Thanks for your answer! This gets me to style the background of the tabs. However, I also need to style the little line under the tabs. – Hidde May 12 '12 at 22:30