How to change the font size of tabhost in android

ReNa picture ReNa · Apr 26, 2011 · Viewed 48.7k times · Source

How can the font size of the tabs be changed? I extend TabActivity for the tabs.

Answer

rekaszeru picture rekaszeru · Apr 26, 2011

You can define themes, use styles to achieve this:

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>

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).