3

因此,我非常難以使用xml來設置選項卡的樣式。我搜索過的每個地方似乎都建議以編程方式執行此操作的解決方案,或者引用actionBarTab樣式>:|樣式選項卡使用XML的小部件

我所試圖實現的是從使用http://android-holo-colors.com/

產生的tabwidget可繪製自定義的標籤我設法得到

所以在我的自定義主題,我有這樣的代碼:

<style name="RR.App.Theme" parent="android:Theme.Holo.Light"> 
... 
<item name="android:tabWidgetStyle">@style/RR.Tab.Widget</item> 
... 
</style> 

這是RR.Tab.Widget風格:(都未似乎使這種差異)

<style name="RR.Tab.Widget" parent="android:Widget.Holo.Light.TabWidget"> 
<item name="android:background">@drawable/rrtheme_tab_indicator_holo</item> 
<item name="android:tabStripEnabled">false</item> 
<item name="android:tabStripLeft">@null</item> 
<item name="android:tabStripRight">@null</item> 
</style> 

這是生成的繪製:

<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/rrtheme_tab_unselected_holo" /> 
    <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/rrtheme_tab_selected_holo" /> 

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

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

    <!-- Focused states --> 
    <item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/rrtheme_tab_unselected_pressed_holo" /> 
    <item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/rrtheme_tab_selected_pressed_holo" /> 
</selector> 

這是它目前的樣子: enter image description here

所有我想要做的就是改變這種藍色至綠色!

爲您的幫助提前:)

回答

4

非常感謝,我建議你去看看這個: Customize Tab indicator(死鏈接)

也有你的標籤定義使用Android Action Bar Style Generator。我總是用它來使我的標籤具有我想要的顏色。

希望我幫你

+0

輝煌,感謝您的幫助。由於我使用的是棄用的TabActivity,因此需要更新才能首先使用片段和頁面查看器。我可能會在接下來打這個,所以我會在完成後發佈我的方法。 – Samuroid

相關問題