0

I want to set font size of my TabWidget title. I have 6 tabs with the following titles:

Delhi | Mumbai | New york | Shahnghai | Chicago | Sydney

The screen is not able to show full text of title. Therefore, I want to reduce the font size of only title of the tabs and no where else.

Thanks Aman

Tiago Almeida
  • 14,081
  • 3
  • 67
  • 82
Amandeep Singh
  • 3,754
  • 8
  • 51
  • 72

1 Answers1

0

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!

Community
  • 1
  • 1
Barney
  • 2,355
  • 3
  • 22
  • 37