David Silva
David Silva

Reputation: 2017

TabLayout - selected tab with different font

Is there any way to set a different font on the tab that is currently selected (in TabLayout) ?

To use custom fonts I use Calligraphy, but I am looking for any way to define different font for the currently selected tab.

Upvotes: 1

Views: 1089

Answers (1)

pawegio
pawegio

Reputation: 1732

TabLayout is a ViewGroup so you can access its children with getChildAt(selectedPosition). Then you can iterate over TabItem children (as by default its LinearLayout containing single ImageView and single TextView) and if you find a TextView instance execute TextView.setTypeface() passing desired font as an argument.

Upvotes: 1

Related Questions