Text size of android design TabLayout tabs

Malko picture Malko · Jul 17, 2015 · Viewed 115k times · Source

I have difficulties changing the text size of the tabs of design library tablayout (android.support.design.widget.TabLayout).

I managed to change it by assigning tabTextAppearance in TabLayout

app:tabTextAppearance="@style/MyTabLayoutTextAppearance"

the following style

<style name="MyTabLayoutTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse">
    <item name="android:textSize">14sp</item>
</style>

but I have 2 side effects :

1) I lost the accent color of the selected tab

2) The tab text is not capitalized any more.

Answer

hnrain picture hnrain · Aug 5, 2015
<style name="MineCustomTabText" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">16sp</item>
</style>

Use is in TabLayout like this

<android.support.design.widget.TabLayout
            app:tabTextAppearance="@style/MineCustomTabText"
            ...
            />