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.我一直使用它来使标签具有所需的颜色.
希望我能帮助你
标签:android-styles,android-theme,tabwidget,android,android-tabs 来源: https://codeday.me/bug/20191029/1962773.html