I use a tabLayout
and wanna change the font weight of the selected tab. I just find the configuration of the indicator, selected font and background color, but not the font weight to bold.
Asked
Active
Viewed 703 times
0

emen
- 6,050
- 11
- 57
- 94

michael-mammut
- 2,595
- 5
- 28
- 46
-
see https://stackoverflow.com/questions/31947165/how-to-set-font-weight-as-light-regular-in-android – Jakob F Feb 11 '20 at 16:11
-
Does this answer your question? [How to set font weight as light, regular in Android](https://stackoverflow.com/questions/31947165/how-to-set-font-weight-as-light-regular-in-android) – Jakob F Feb 11 '20 at 16:11
1 Answers
1
From what you said about being able to configure the selected font this should be easy and you can achieve this by setting a Typeface on the textview of your selected tab. Just as you would set a typeface for a texview.
Add OnTabSelectedListener
to your tabLayout. in onTabSelected
iterate through the tab's childViews to and check if its an instance of TextView, then set a Typeface.BOLD to that textview (or set a custom font of your choice).
Similarly in onTabUnselected
you need to set the Typeface back to Typeface.NORMAL (or your default font).
Maybe this post can be of some help. I don't think there's any direct way to simply set a tab's selected font weight yet.

ljk
- 1,496
- 1
- 11
- 14