how to change the color of the text indicator of tab? i can change the icon using selector tag refered the example. but cant to the text color. how?
Style it in your custom theme change
<item name="tabWidgetStyle">@android:style/Widget.TabWidget</item>
and
<style name="Widget.TabWidget">
<item name="android:textAppearance">@style/TextAppearance.Widget.TabWidget</item>
<item name="ellipsize">marquee</item>
<item name="singleLine">true</item>
</style>
<style name="TextAppearance.Widget.TabWidget">
<item name="android:textSize">14sp</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">@android:color/tab_indicator_text</item>
</style>
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.