【发布时间】:2011-04-21 09:25:18
【问题描述】:
我想将文本放在我的应用程序的每个选项卡上,并且还想改变它的默认颜色。 . .怎么可能?
【问题讨论】:
-
请你停止标记你的问题 android-ndk,这很烦人。它们与 NDK没有任何关系。
标签: android android-emulator android-layout android-widget
我想将文本放在我的应用程序的每个选项卡上,并且还想改变它的默认颜色。 . .怎么可能?
【问题讨论】:
标签: android android-emulator android-layout android-widget
我在我的一个应用程序中为选项卡定义了自定义样式。
类似于:
(注意:在styles.xml文件中定义这个样式)
<?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>
并在 AndroidManifest.xml 文件中的应用程序标签中给出这个主题:
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/MyTheme">
您仍然已经完成了问题的解决方案,让我提出一个同样有效的示例:how to change the color of the tabs indicator text in android?
【讨论】:
类似的东西:
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));
【讨论】:
这是一个这样做的例子,
TabSpec pecHome = tabHost.newTabSpec("Home").setIndicator("Home",
res.getDrawable(R.drawable.home)).setContent(intentHome);
tabHost.addTab(specHome);
这里 ssetIndicator 将使您能够显示文本。
仅此而已 最好的问候 阿努普
【讨论】: