I am using android.support.design.widget.BottomNavigationView from design support library version 25
compile 'com.android.support:design:25.0.0'
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
app:itemBackground="@color/colorPrimary"
app:menu="@menu/bottom_navigation_main"
android:forceHasOverlappingRendering="true"/>
When there are only three actions in @menu/bottom_navigation_main, it displays both icons and text labels at all times.
What is the way to display both icons and text labels at all the time when there are more than three actions.
Here's a Kotlin extension function that combines @STAR_ZERO and @KishanSolanki124's solution.
To use it:
It is difficult in version 25.
Try this code. But I think it's not good solution.
Are you want to this effect ?
If so, I recommended you to try BottomNavigationViewEx。
To show the titles all the way. Try this Kotlin code:
in BottomNavigationView class there is a BottomNavigationMenuView field and in BottomNavigationMenuView there is a BottomNavigationItemView[] field, which is the items in the bottom bar.
Say n is the number of items, BottomNavigationMenuView will call BottomNavigationItemView.setShiftingMode(n>3) on each member of the BottomNavigationItemView[] array. This function decides the behaviour (show title always or only upon selection).
so the way to always show the titles is to try to call this method and you can use reflection to access the private fields.
try this,worked for me