使用XML样式化选项卡小部件

3
我正在尝试使用xml样式化标签小部件,但遇到了困难。我搜索了很多地方,似乎要么建议以编程方式解决此问题,要么涉及到actionBarTab风格。 我想实现的是从使用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>

这是当前的界面: 在此输入图片描述 我想做的就是将这个蓝色改为绿色!
非常感谢你提前帮助 :)
1个回答

4

太棒了,感谢你的帮助。由于我正在使用已弃用的TabActivity,因此需要先更新为使用片段和页面查看器。我可能会接下来处理这个问题,完成后我会发布我的方法。 - Sambuxc

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接