使用XML样式化标签小部件的样式 [英] Styling Tab Widget's using XML

查看:62
本文介绍了使用XML样式化标签小部件的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,使用xml设置标签小部件的样式非常困难.我搜索过的所有地方似乎都建议以编程方式建议解决方案,或者引用actionBarTab样式>:|

So I am having great difficultly styling tab widgets using xml. Everywhere I have searched seem's to either suggest solutions to do this programmatically, or refers to the actionBarTab style >:|

我要实现的是使用 http://生成的tabwidget可绘制对象的自定义标签android-holo-colors.com/

我设法得到

因此在我的自定义主题中,我有以下代码:

So in my custom theme I have this code:

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

这是RR.Tab.Widget样式:(这些似乎都没有什么不同)

This is the RR.Tab.Widget style: (none of these seem to make such difference)

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

这是生成的可绘制对象:

This is the generated 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>

这是当前的样子:

我要做的就是将这种蓝色更改为绿色!

All I'm trying to do is change this blue color to green!

非常感谢您的提前帮助:)

Many thanks for your help in advance :)

推荐答案

我建议您看一下: 自定义标签指示符(无效链接)

I recommend you to take a look at this: Customize Tab indicator (dead link)

还要自定义标签,请使用 Android操作栏样式生成器.我总是使用它以我想要的颜色显示我的标签.

Also to have your tab customized use Android Action Bar Style Generator. I always use it to have my Tabs in the color I want.

希望我能帮助您

这篇关于使用XML样式化标签小部件的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆