Android Tab Text color

Altaf picture Altaf · Mar 1, 2011 · Viewed 28.6k times · Source

Possible Duplicate:
Android: Change Tab Text Color Programmatically

How can we change the text color in android tab.

Answer

isneesh picture isneesh · Sep 13, 2011

I use the ColorStateList, find it more elegant. Here is an example :

tab_text.xml :

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

In your TextView, just set the textColor to point to this file with :

android:textColor="@color/tab_text"