How to Change Fonts in material Tab Layout’s tabs

Brisk Android
Nov 19, 2020

First Of All...

Go through this URL to have a quick recap on what we are going to talk about

Now,

Follow these 3 steps to customize your fonts in tabs

Design your TabLayout in XML

2. Add the style to customize your font

In the above code snippet, you might have observed this line which has the sole purpose of updating the tab’s text appearance according to our needs

app:tabTextAppearance=”@style/TabFont”

So we have to add this code to the style.xml file

<style name=”TabFont” parent=”TextAppearance.Design.Tab”>

<item name=”android:fontFamily”>@font/architects_daughter</item>

<item name=”android:textSize”>20sp</item>

<item name=”textAllCaps”>false</item> </style>

Note: There is no need to write the exact style name, you can use whatever name you want to write

Note: Remember to use the parent as TextAppearance.Design.Tab

as this will help in changing the style of the tab.

3. You’re done implementing custom Fonts in your tab layout

You can multiple ways to interact with your tab layout

You can use viewpager to associate tabs with it and interact accordingly

or you can use the addOnTabSelectedListener callback method to interact with your tabs

If you are still confused; Use this youtube Tutorial video to help yourself

The source-code link is here:

Thank You for reading this…

Enjoy and Happy Coding!

--

--