I have created a bottom bar navigation in my android page. But now I want to apply the custom font-family in bottom navigation texts.
This is the bottom navigation c
public void setNavigationTypeface() {
final Typeface avenirHeavy = Typeface.createFromAsset(this.getAssets(), "font2/Avenir-Heavy.ttf"); //replace it with your own font
ViewGroup navigationGroup = (ViewGroup) bottomNavView.getChildAt(0);
for (int i = 0; i < navigationGroup.getChildCount(); i++) {
ViewGroup navUnit = (ViewGroup) navigationGroup.getChildAt(i);
for (int j = 0; j < navUnit.getChildCount(); j++) {
View navUnitChild = navUnit.getChildAt(j);
if (navUnitChild instanceof BaselineLayout) {
BaselineLayout baselineLayout = (BaselineLayout) navUnitChild;
for (int k = 0; k < baselineLayout.getChildCount(); k++) {
View baselineChild = baselineLayout.getChildAt(k);
if (baselineChild instanceof TextView) {
TextView textView = (TextView) baselineChild;
textView.setTypeface(avenirHeavy);
}
}
}
}
}
}