how to change the color of the tabs indicator text in android?

Here is a new answer I found from Fred Grott (http://knol.google.com/k/fred-grott/advance-tabs/) after a little web searching.

This lets you set a selector for text color so a different color can be used when tab is selected or not. Which can be very useful if you are using a different background color for the tab if its selected. Of course you can also just throw in a plain color and not a selector.

final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);        
tv.setTextColor(this.getResources().getColorStateList(R.color.text_tab_indicator));

Where R.color.text_tab_indicator is a selector xml file located in your res/drawable folder.

In other words, the indicator text really is a TextView which is retrievable via the View object which can be accessed from the TabWidget object.

Take a look at Fred’s examples for more info and context regarding the variable declarations as well as other tricks.

Leave a Comment