我想设置我的 TabWidget 标题的字体大小。我有 6 个标签,标题如下:
德里 | 孟买 | 纽约 | 上海 | 芝加哥 | 悉尼
屏幕无法显示标题的全文。因此,我想减少选项卡标题的字体大小,而不是其他地方。
谢谢阿曼
Create a styles.xml
that defines the font size for your TabWidget
and put the file under res/values
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<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">desired_font_size_in_sp</item>
</style>
</resources>
Then, specify the theme you just defined in your manifest file by adding the following under the <activity>
tag of your tab activity:
android:theme="@style/CustomTheme"
This answer is actually borrowed from: How to change the font size of tabhost in android
Hope this helps!