1

I followed the answer from here: StackOverflow: How to change the font size of tabhost in android

It does work, but I lose the Holo theme, and get an old default theme instead. So I tried the following:

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

Essentially what I have done is edit the original definition of Widget.Holo.Tabwidget available here@line:1801 to include a custom definition for textAppearance.

I get the following error:

error: Error: No resource found that matches the given name: attr 'android:tabLayout'.

I just want to change the font size of the tab titles while retaining the Holo theme.

Community
  • 1
  • 1
janakagamini
  • 237
  • 3
  • 11

1 Answers1

15

Try this once

for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
        TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
        tv.setTextSize(23);
    }
NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98
User
  • 1,251
  • 1
  • 14
  • 19
  • Thanks Madhavi. This certainly works. I wonder whether there is a way to do it through xml though? If I wanted to further customize the look of the tab (inheriting from the Holo theme), doing it in Java seems troublesome. – janakagamini Dec 14 '12 at 01:54