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