Action Bar Sherlock,改变标签下的线条颜色?

时间:2012-08-24 10:56:50

标签: android actionbarsherlock

如何更改突出显示的Action Bar Sherlocks选项卡下显示的线条的颜色。

默认是电蓝色。

1 个答案:

答案 0 :(得分:0)

这是一个基于google i/o app实现的实现:

设置主题样式:

<style name="Theme.Styled" parent="Theme.Sherlock.Light">

    <item name="android:actionBarTabBarStyle">@style/Widget.Styled.TabBar</item>
    <item name="actionBarTabBarStyle">@style/Widget.Styled.TabBar</item>

</style>

 <style name="Widget.Styled.TabView" parent="Widget.Sherlock.Light.ActionBar.TabView">
    <item name="android:background">@drawable/tab_white_ab</item>
</style>

像这样创建一个drawable - 请注意,在谷歌I / O应用程序中,非聚焦状态是透明的 - 在下面的示例中,我将透明变为绿色:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false"
    android:state_selected="false"
    android:state_pressed="false"
    android:drawable="@drawable/tab_green_unselected"
             />
    <!--  android:drawable="@android:color/transparent"-->

<item android:state_focused="false"
    android:state_selected="true"
    android:state_pressed="false"
    android:drawable="@drawable/tab_white_selected" />

<!-- Focused states -->
<item android:state_focused="true"
    android:state_selected="false"
    android:state_pressed="false"
    android:drawable="@drawable/item_focused" />
<item android:state_focused="true"
    android:state_selected="true"
    android:state_pressed="false"
    android:drawable="@drawable/tab_white_selected_focused" />

<!-- Pressed -->
<!--    Non focused states -->
<item android:state_focused="false"
    android:state_selected="false"
    android:state_pressed="true"
    android:drawable="@drawable/item_pressed" />
<item android:state_focused="false"
    android:state_selected="true"
    android:state_pressed="true"
    android:drawable="@drawable/tab_white_selected_pressed" />

<!--    Focused states -->
<item android:state_focused="true"
    android:state_selected="false"
    android:state_pressed="true"
    android:drawable="@drawable/item_focused" />
<item android:state_focused="true"
    android:state_selected="true"
    android:state_pressed="true"
    android:drawable="@drawable/tab_white_selected_pressed" />

希望这有帮助。