我按照这里的答案:StackOverflow: How to change the font size of tabhost in android
它确实有效,但我丢失了Holo主题,并改为使用旧的默认主题。所以我尝试了以下内容:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Holo.NoActionBar.Fullscreen">
<!-- API 14 theme customizations can go here. -->
<item name="android:tabWidgetStyle">@style/CustomHoloTabWidget</item>
</style>
<style name="CustomHoloTabWidget" parent="@android:style/Widget.TabWidget">
<!-- Custom item for text appearance -->
<item name="android:textAppearance">@style/CustomTabWidgetText</item>
<!-- End -->
<item name="android:tabStripLeft">@null</item>
<item name="android:tabStripRight">@null</item>
<item name="android:tabStripEnabled">false</item>
<item name="android:divider">?android:attr/dividerVertical</item>
<item name="android:showDividers">middle</item>
<item name="android:dividerPadding">8dip</item>
<item name="android:measureWithLargestChild">true</item>
<!-- Following line results in ERROR -->
<item name="android:tabLayout">@android:layout/tab_indicator_holo</item>
<!-- End -->
</style>
<!-- Custom text appearance item definition -->
<style name="CustomTabWidgetText" parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">36sp</item>
<item name="android:textStyle">bold</item>
</style>
<!-- End -->
基本上我所做的就是编辑Widget.Holo.Tabwidget的原始定义here@line:1801,以包含textAppearance的自定义定义。
我收到以下错误:
错误:错误:找不到与给定名称匹配的资源:attr'android:tabLayout'。
我只想在保留Holo主题的同时更改标签标题的字体大小。
答案 0 :(得分:15)
尝试一次
for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
tv.setTextSize(23);
}