【问题标题】:How to Change the default BLUE border of Tab Bar in Sherlock Action Bar?如何更改 Sherlock 操作栏中标签栏的默认蓝色边框?
【发布时间】:2013-10-16 10:42:08
【问题描述】:

我在 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>

代码运行良好。但我想更改默认的蓝色底边框。请提供解决方案!

【问题讨论】:

    标签: android actionbarsherlock tabview


    【解决方案1】:

    主题中有几种样式会影响操作栏中的选项卡。要设置标签的样式,您必须在主题中设置以下样式:(android:)actionBarTabBarStyle(android:)actionBarTabStyle(android:)actionBarTabTextStyle(括号表示所有版本 - 原生操作栏、ActionBarSherlockActionBarCompat)。

    (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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-15
      • 2012-07-31
      • 1970-01-01
      • 1970-01-01
      • 2012-11-18
      • 1970-01-01
      相关资源
      最近更新 更多