2012-10-18 126 views
1

要更改顏色或背景全部ACtionBar標籤,我可以使用actionBar.setStackedBackgroundDrawable()ActionBar僅更改選定選項卡的顏色/可繪製?

但是,如何更改所選標籤的顏色或可繪製?例如,製表符的背景顏色是黑色的,但是當我選擇一些製表符時,我希望它是紅色的。

可能做到這一點,因爲我一直無法找到有關此問題的主題。

回答

5

將選擇被用於標籤:

<style name="Custom" parent="@style/Theme.Sherlock"> 
    <item name="actionBarTabStyle">@style/Widget.Custom.TabView</item> 

    <item name="android:actionBarTabStyle">@style/Widget.Custom.TabView</item> 
</style> 

<style name="Widget.Custom.TabView" parent="@style/Widget.Sherlock.ActionBar.TabView"> 
    <item name="android:background">@drawable/your_custom_selector</item> 
</style> 

退房ABS中可繪製名爲abs__tab_indicator_ab_holo.xml關於如何創建your_custom_selector參考。

你想改變任何有android:state_selected="true"

相關問題