Creating Actionbarsherlock Tabs

So, I'm trying to create the tabs of my Actionbar, which I 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>

On the second and third lines, if I change actionBarTabStyle to actionBarStyle, my action bar changes to my desired style (not very good, of course), so the connections really work. However, trying to change the tabs on the action bar (below) is still not successful.

I hope someone can help me.

Yours faithfully,

+3
source share
3 answers

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 the BarTabBarStyle action twice. This is due to Android> 3.0 and Android <3.0.

+13

CustomActionBarStyle

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

, :)

+5

Thus, I had some difficulties with the style due to the specific method that I found to add tabs by code in the first place. Thanks for the answers, they all work.

0
source

All Articles