我很努力与样式的ActionBar。我的应用程序有一个带三个选项卡的ActionBar。我试图让选定的标签具有背景颜色,而未选中的标签显示不同的颜色。我遵循这个参考:Customizing Action Bar。但是所有的TAB都显示了“选定的颜色”。如何样式的ActionBar,在选定的选项卡上的标签背景
我styles.xml
文件如下:
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBar.TabBar">
<item name="android:background">@drawable/tab_background</item>
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>
<style name="MyActionBarTabBarStyle" parent="android:style/Widget.Holo.Light.ActionBar.TabBar">
<item name="android:background">@drawable/red</item>
</style>
<style name="AppTheme.Light" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBar.Light</item>
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="android:actionBarTabBarStyle">@style/MyActionBarTabBarStyle</item>
</style>
tab_background只是一个9补丁。我也不确定是否继承了正确父级的操作栏选项卡(parent="android:style/Widget.Holo.Light.ActionBar.TabBar
)。我查看了参考文献&发现很难理解风格层次结构
为什么我的选项卡不显示选择或不显示?提前感谢你的帮助。
使用[ActionBarSherlockStyleGenerator](http://jgilfelt.github.com/android-actionbarstylegenerator/ #name = example&compat = holo&theme = light&actionbarstyle = solid&backColor = E4E4E4,100&secondaryColor = D6D6D6,100&tertiaryColor = F2F2F2,100&accentColor = 33B5E5,100)来设计和使用。检查我的答案[这里](http://stackoverflow.com/questions/13269482/change-background-of-the-actionbarsherlock-alone-not-the-tabs/13283261#13283261) – PravinCG
谢谢普拉万。 ActionBarStyleGenerator对于ActionBar风格非常有用 – CocoNess