I want to put the text on the every tab of开发者_如何学Go my application and also want to change its color from default. . . How it is Possible ?
I have defined a custom style for tab in my one of the application.
Which is something like:
(Note: define this style inside the styles.xml file)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="@android:style/Theme.Light">
<item name="android:tabWidgetStyle">@style/LightTabWidget</item>
</style>
<style name="LightTabWidget" parent="@android:style/Widget.TabWidget">
<!-- set textColor to red, so you can verify that it applied. -->
<!-- <item name="android:textColor">#f00</item> -->
<item name="android:textSize">12px</item>
<item name="android:textColor">#1E90FF</item>
</style>
</resources>
and give this theme in the application tag inside AndroidManifest.xml file as:
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/MyTheme">
Update:
Still you are already done with solutions for the problem, let me suggest an example which is also valid: how to change the color of the tabs indicator text in android?
Something like that:
private View createTabIndicator(String text) {
Button button = new Button(this);
button.setBackgroundResource(R.drawable.tab);
button.setText(text);
button.setTextColor(Color.WHITE);
button.setGravity(Gravity.CENTER);
return button;
}
...
getTabHost().addTab(getTabHost().newTabSpec("name").setIndicator(createTabIndicator("name")).setContent(data));
Here is an example of doing this,
TabSpec pecHome = tabHost.newTabSpec("Home").setIndicator("Home",
res.getDrawable(R.drawable.home)).setContent(intentHome);
tabHost.addTab(specHome);
here ssetIndicator will enable you to display the text.
Thats all Best Reagrds Anup
精彩评论