首页 > 代码库 > 更改android actionbar tab文字颜色

更改android actionbar tab文字颜色

1 在res/values/colors.xml

<color name="text_tab_selected">#000000</color>

<color name="text_tab_unselected">#886C2A</color>


2 /res/color 定义文件 tab.xml

<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.androdid.com/apk/res/android">   <item android:state_selected="true" android:color="@color/text_tab_selected" />   <item android:state_active="true" android:color="@color/text_tab_selected"/>   <item android:state_selected="false" android:color="@color/text_tab_unselected" />  <item android:state_active="false" android:color="@color/text_tab_unselected"/></selector>

3 res/values/styles.xml

<style name="TabTextColor" parent="@style/Widget.Sherlock.ActionBar.TabText">   <item name="android:textColor">@color/tab_text</item>  </style>

4 在同个文件

style name="Theme.yourTheme" parent="@style/Theme.Sherlock">

<item name="actionBarTabTextStyle">@style/TabTextColor</item><item name="android:actionBarTextStyle>@style/TabTextColor</item>

5
来自 http://stackoverflow.com/questions/11393400/tabs-text-custom-color-in-sherlock-action-bar