我想更改Tab Bar的高亮颜色。我还将使用Android Action Bar Style Generator来改变颜色,但不会改变颜色。
Style.xml
<resources>
<style name="Theme.Example" parent="@android:style/Theme.Holo">
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Example</item>
</style>
<style name="ActionBarTabStyle.Example" parent="@android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_example</item>
</style>
</resources>
tab_indicator_ab_example
<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="@android:color/transparent" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_example" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused_example" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_focused_example" />
<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_example" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_example" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_example" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_example" />
</selector>
Plz指导我更改标签栏的突出显示颜色
答案 0 :(得分:3)
我已将此代码添加到我的应用中。现在您可以轻松地将此代码添加到您的应用程序中,并且我可以随意使用它。
请将此文件放在您的可绘制文件夹中,并将此文件设置为您的背景。
tab_bg_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/tab_selected" android:state_pressed="true"/>
<item android:drawable="@color/tab_selected" android:state_selected="true"/>
<item android:drawable="@color/tab_normal"/>
</selector>
将此代码放入您的资源 - &gt;值 - &gt; color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name = "tab_normal"> #FF0000 </color>
<color name = "tab_selected"> #000000 </color>
</resources>
答案 1 :(得分:0)
尝试使用http://jgilfelt.github.io/android-actionbarstylegenerator/这是最简单的方法..
1)使用UI为不同的项目选择颜色
2)完成后点击“DOWNLOAD .ZIP”
3)ZIP文件包含您必须在项目res / layout和res / drawableXXXX文件夹中复制的资源文件