微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android-使用XML样式化标签小部件

所以我很难使用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>

这是生成的drawable:

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

这是当前的样子:

要做的就是将此蓝色更改为绿色!

非常感谢您的帮助:)

解决方法:

我建议您看一下:
Customize Tab indicator(死链接)

另外,还可以自定义标签,使用Android Action Bar Style Generator.我一直使用它来使标签具有所需的颜色.

希望我能帮助你

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐