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!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Brisk Android
Brisk Android

Written by Brisk Android

0 Followers

Android App Developer

No responses yet

Write a response