After adding 4 items in my menu.xml file for the BottomNavigationView it shows only selected item title and hides all other titles. Can I force showing the title and the icon. here is my code.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_home"
android:enabled="true"
android:icon="@drawable/ic_home_24dp"
android:title="@string/text_home"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_category"
android:enabled="true"
android:icon="@drawable/ic_grid_24dp"
android:title="@string/text_category"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_me"
android:enabled="true"
android:icon="@drawable/ic_me_24dp"
android:title="@string/text_me"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_setting"
android:enabled="true"
android:icon="@drawable/ic_cog_24dp"
android:title="@string/text_setting"
app:showAsAction="ifRoom" />
</menu>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/white"
android:elevation="6dp"
android:translationZ="6dp"
app:menu="@menu/bottom_navigation_main" />
Try this code,
activity_main.xml :
fragment_menu.xml :
Make this file inside menu folder,
bottom_nav_items.xml :
MainActivity.java :
MenuFragment.java :
whatever you need to do is just disable BottomNavigationView Shift mode, using this method in you code.
call this method like this,
It will work.I am attaching screenshot here,