如何在android中更改tabhost的字体大小
问题描述:
如何改变标签的字体大小?我为标签扩展了 TabActivity.
How can the font size of the tabs be changed? I extend TabActivity for the tabs.
答
你可以定义主题,使用样式来实现:
You can define themes, use styles to achieve this:
首先在 res/values/styles.xml
中为 Activity
创建主题(名称:CustomTheme
):
First you create the theme (name:CustomTheme
) for your Activity
in your res/values/styles.xml
:
<style name="CustomTheme" parent="@android:style/Theme">
<item name="android:tabWidgetStyle">@style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="@android:style/Widget.TabWidget">
<item name="android:textAppearance">@style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText"
parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>
</style>
然后在您的 androidManifest.xml
中为包含您的 TabWidget
的 TabActivity
或 Activity
指定上述主题:
Then in your androidManifest.xml
you specify the theme above for your TabActivity
or Activity
containing your TabWidget
:
<activity android:name="MyTabActivity" android:theme="@style/CustomTheme">
这将为您提供所需的输出(当然,您应该根据自己的喜好更改大小和样式).
This will serve you with the output you want (of course you should change the size and style for your preference).