Hidde
Hidde

Reputation: 374

Styling the Actionbarsherlock tabs

So I'm trying to style the tabs of my Actionbar, which I've implemented using the ActionBarSherlock library. This is my code:

<style name="Theme.AndroidDevelopers" parent="Theme.Sherlock.Light.ForceOverflow">
                <item name="actionBarTabStyle">@style/CustomActionBarStyle</item>
                <item name="android:actionBarTabStyle">@style/CustomActionBarStyle</item>

            <style name="CustomActionBarStyle" parent="Widget.Sherlock.Light.ActionBar.TabBar">
                <item name="android:background">@drawable/actionbar_tab_bg</item>
            </style>

At the second and third line, if I change actionBarTabStyle to actionBarStyle, my actionbar itself is changed to my wanted style (not very well, ofcourse), so the connections do work. However, trying to change the actionbar tabs (below it), has still no success.

I hope somebody can help me.

With Regards,

Upvotes: 3

Views: 7141

Answers (3)

Hidde
Hidde

Reputation: 374

So I had some difficulties with the styling because of a certain way I found to add the tabs by code in the first place. Thank you for the responses, they all work.

Upvotes: 0

JorgeDeCorte
JorgeDeCorte

Reputation: 787

The following should work

<style name="Theme.app" parent="@style/Theme.Sherlock.Light">
        <item name="android:actionBarTabBarStyle">@style/Theme.app.tabbar.style</item>
        <item name="actionBarTabBarStyle">@style/Widget.app.ActionBar.TabBar</item>
</style>

<style name="Theme.app.tabbar.style" parent="@style/Theme.Sherlock.Light">
    <item name="android:background">#FF0000</item>
    <item name="background">#FF0000</item>
</style>

<style name="Widget.app.ActionBar.TabBar" parent="Widget.Sherlock.ActionBar.TabBar">
    <item name="android:background">#FF0000</item>
    <item name="background">#FF0000</item>
</style>

This makes the tabBar red.

You need to set two times the actionBarTabBarStyle. This is because of Android > 3.0 and Android <3.0

Upvotes: 13

chuckliddell0
chuckliddell0

Reputation: 2061

In your CustomActionBarStyle you need to have

<item name="android:background">@drawable/actionbar_tab_bg</item>
<item name="background">@drawable/actionbar_tab_bg</item>

Hope this helps :)

Upvotes: 5

Related Questions