BottomNavigationView - How to uncheck all MenuItems and keep Titles being displayed?

Victor R. Oliveira picture Victor R. Oliveira · Dec 29, 2016 · Viewed 11.5k times · Source

As I liked the design from BottomNavigationView I decided to implement a new Menu for my App with it, instead of just using simple buttons.

I took this post as a guideline.

According to BottomNavigationView's documentation, its purpose is to

provide quick navigation between top-level views of an app. It is primarily designed for use on mobile.

In my case, I just want each MenuItem to launch an activity, but by default there is always one MenuItem selected:

enter image description here

I tried to set the color to white with:

app:itemIconTint="@color/white"
app:itemTextColor="@color/white"

Still, visibly selected MenuItem is different from others (Title size bigger), which is still bothering me:

enter image description here

I came with the idea to place a hidden MenuItem to select like:

<item
android:id="@+id/uncheckedItem"
android:title="" />

and make its view GONE:

 bottomNavigationView.getMenu().findItem(R.id.uncheckedItem).setChecked(true);
 bottomNavigationView.findViewById(R.id.uncheckedItem).setVisibility(View.GONE);

This makes all MenuItems unchecked, but by default BottomNavigationView is hidding Titles, as it has more than 3 MenuItems to display, even if the fourth MenuItem is settle to GONE:

enter image description here

So my question remains, is there away/hack to unselect all MenuItems and keep its titles being displayed?

Answer

Rony Tesler picture Rony Tesler · Mar 21, 2018
mNavigationBottom.getMenu().setGroupCheckable(0, false, true);