如何更改Sherlock Action Bar中选项卡栏的默认蓝色边框?
问题描述:
我已经在SO ..中搜索了很多,但没有得到任何工作解决方案。我想要更改标签栏底部的标签栏的默认蓝色。我可以更改标签的颜色但不能改变底部的蓝色。我知道它使用了默认的9个补丁图像。但是如何改变那个使用自定义风格的主题?如何更改Sherlock Action Bar中选项卡栏的默认蓝色边框?
这是我xml..where我做我的标签查看更改的一部分。这
<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>
的代码工作perfectly.But我想更改默认的蓝色底部边框。请提供解决方案!
答
主题中有几种样式会影响操作栏中的选项卡。要设置选项卡的样式,您必须在主题中设置以下样式:(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>