问题
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,
回答1:
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
回答2:
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 :)
回答3:
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.
来源:https://stackoverflow.com/questions/10284962/styling-the-actionbarsherlock-tabs