我在SO中搜索了很多...但是没有任何有效的解决方案。我想更改标签栏底部的标签栏的默认蓝色。我可以更改颜色选项卡但无法更改底部的蓝色。我知道它使用默认的9个补丁图片。但是如何使用自定义样式主题更改它?
这是我的xml ..我正在为我的标签视图进行更改..
<style name="MyTheme" 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">#80aa01</item>
<item name="background">#80aa01</item>
<style name="Widget.app.ActionBar.TabBar" parent="Widget.Sherlock.ActionBar.TabBar">
<item name="android:background">#80aa01</item>
<item name="background">#80aa01</item>
代码工作正常。但我想更改默认的蓝色底部边框。请提供解决方案!!
答案 0 :(得分:0)
主题中有多种样式会影响操作栏中的标签。要设置标签样式,您必须在主题中设置以下样式:(android:)actionBarTabBarStyle
,(android:)actionBarTabStyle
和(android:)actionBarTabTextStyle
(括号表示所有版本 - 原生操作栏,ActionBarSherlock
和ActionBarCompat
)。
(android:)actionBarTabBarStyle
会影响整个标签栏。标签栏可以是“堆叠操作栏”(主操作栏下方的整个栏)或主操作栏的一部分(横向)。使用该样式,您可以更改所有选项卡背后的背景(所有选项卡的背景一起)。
(android:)actionBarTabStyle
影响单个标签。如果要更改蓝线,则必须在样式中设置背景。默认背景是color state list,它定义了所有状态的背景(所选状态的蓝线)。
(android:)actionBarTabTextStyle
会在单个标签中影响标题。您可以更改标题的大小,颜色和其他属性。
您的主题应包含以下内容:
<style name="AppTheme" parent="@style/Theme.Sherlock.Light">
<item name="android:actionBarTabBarStyle">@style/MyActionBarTabBarStyle</item>
<item name="actionBarTabBarStyle">@style/MyActionBarTabBarStyle</item>
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="android:actionBarTabTextStyle">@style/MyActionBarTabTextStyle</item>
<item name="actionBarTabTextStyle">@style/MyActionBarTabTextStyle</item>
</style>
样式应该是这样的:
<style name="MyActionBarTabBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.TabBar">
<item name="android:background">@drawable/tab_bar_background</item>
</style>
<style name="MyActionBarTabStyle" parent="@style/Widget.Sherlock.Light.ActionBar.TabView">
<!-- to change the blue line, change the background here -->
<item name="android:background">@drawable/tab_background</item>
</style>
<style name="MyActionBarTabTextStyle" parent="@style/Widget.Sherlock.Light.ActionBar.TabText">
<!-- change text attributes here -->
</style>