Используйте этот метод, чтобы все метки BottomNavigationView
отображались в 2 строки:
private void fixBottomNavigationText(BottomNavigationView bottomNavigationView) {
for (int i = 0; i < bottomNavigationView.getChildCount(); i++) {
View item = bottomNavigationView.getChildAt(i);
if (item instanceof BottomNavigationMenuView) {
BottomNavigationMenuView menu = (BottomNavigationMenuView) item;
for (int j = 0; j < menu.getChildCount(); j++) {
View menuItem = menu.getChildAt(j);
View small = menuItem.findViewById(android.support.design.R.id.smallLabel);
if (small instanceof TextView) {
((TextView) small).setLines(2);
}
View large = menuItem.findViewById(android.support.design.R.id.largeLabel);
if (large instanceof TextView) {
((TextView) large).setLines(2);
}
}
}
}
}
и позвоните по номеру:
fixBottomNavigationText(bottomNavigationView);
измените bottomNavigationView
на идентификатор вашего BottomNavigationView
.
Это на Java, и если у вас возникнут проблемы с написанием на Kotlin, дайте мне знать.
Редактировать В Котлине:
fun fixBottomNavigationText(bottomNavigationView: BottomNavigationView) {
for (i in 0 until bottomNavigationView.getChildCount()) {
val item = bottomNavigationView.getChildAt(i)
if (item is BottomNavigationMenuView) {
val menu = item as BottomNavigationMenuView
for (j in 0 until menu.getChildCount()) {
val menuItem = menu.getChildAt(j)
val small: View = menuItem.findViewById(android.support.design.R.id.smallLabel)
if (small is TextView) {
(small as TextView).setLines(2)
}
val large: View = menuItem.findViewById(android.support.design.R.id.largeLabel)
if (large is TextView) {
(large as TextView).setLines(2)
}
}
}
}
}