2

如何更改突出显示的操作栏 Sherlocks 选项卡下显示的线条的颜色。

它的默认值为电蓝色。

4

1 回答 1

0

这里是基于google i/o app implementation 的实现:

设置主题样式:

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

像这样创建一个可绘制对象 - 请注意,在 google 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" />

希望这可以帮助。

于 2012-09-01T06:47:18.787 回答