Last active
March 22, 2018 14:23
-
-
Save babedev/146e2de28570ef53b881ec3d371ad83f to your computer and use it in GitHub Desktop.
Set font by resource ID got BottomNavigationView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun BottomNavigationView.setFont(@FontRes rId: Int) { | |
val menuView = this.getChildAt(0) as BottomNavigationMenuView | |
val menuCount = menuView.childCount | |
(0 until menuCount).forEach { | |
val itemView = menuView.getChildAt(it) as BottomNavigationItemView | |
val titleView = itemView.getChildAt(1) as BaselineLayout | |
val smallLabel = titleView.getChildAt(0) as TextView | |
val largeLabel = titleView.getChildAt(1) as TextView | |
smallLabel.typeface = ResourcesCompat.getFont(context, rId) | |
largeLabel.typeface = ResourcesCompat.getFont(context, rId) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment