Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove bottom navigation view text in android

I use bottom navigation view for my app and want to remove the text under the icon. I looked for it on the internet but still can't find the solution. Did anyone use to deal with this please give me your solution.

enter image description here

All i want is like this:

enter image description here

My code here: The main layout contain a recyclerview and a bottomnavigationview:

<LinearLayout
    android:weightSum="10"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.v7.widget.RecyclerView
        android:layout_marginTop="20dp"
        android:layout_weight="8.5"
        android:id="@+id/recyclerview_menu"
        android:layout_width="match_parent"
        android:layout_height="0dp">

    </android.support.v7.widget.RecyclerView>
    <android.support.design.widget.BottomNavigationView
        android:background="@color/whiteColor"
        android:id="@+id/bottom_navigation_bar"
        android:layout_weight="1.5"
        app:menu="@menu/menu_bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="0dp">

    </android.support.design.widget.BottomNavigationView>
</LinearLayout>

Here is the bottomnavigation menu:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
    android:id="@+id/action_favorites"
    android:enabled="true"
    android:icon="@drawable/ic_search"
    android:title="Home"
    app:showAsAction="ifRoom" />
<item
    android:id="@+id/action_schedules"
    android:enabled="true"
    android:icon="@drawable/ic_search"
    android:title="Search"
    app:showAsAction="ifRoom" />
<item
    android:id="@+id/action_music"
    android:enabled="true"
    android:icon="@drawable/ic_search"
    android:title="Save"
    app:showAsAction="ifRoom" />
<item
    android:id="@+id/action_me"
    android:enabled="true"
    android:icon="@drawable/ic_search"
    android:title="Me"
    app:showAsAction="ifRoom" />

And in MainActivity:

    mBottomBar = (BottomNavigationView) 
    findViewById(R.id.bottom_navigation_bar);
    disableShiftMode(mBottomBar);

    public void disableShiftMode(BottomNavigationView view) {
    BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
    try {
        Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
        shiftingMode.setAccessible(true);
        shiftingMode.setBoolean(menuView, false);
        shiftingMode.setAccessible(false);
        for (int i = 0; i < menuView.getChildCount(); i++) {
            BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
            item.setShiftingMode(false);
            // set once again checked value, so view will be updated
            item.setChecked(item.getItemData().isChecked());
        }
    } catch (NoSuchFieldException e) {
        Log.e("Luan", "Unable to get shift mode field");
    } catch (IllegalAccessException e) {
        Log.e("Luan", "Unable to change value of shift mode");
    }
}
like image 696
Luan Si Ho Avatar asked Aug 29 '17 15:08

Luan Si Ho


People also ask

How do I hide the bottom navigation title in Android?

Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.

How do I hide the bottom of my navigation?

On Android 4.1 and higher, you can set your application's content to appear behind the navigation bar, so that the content doesn't resize as the navigation bar hides and shows. To do this, use SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION .

What is bottom navigation view in Android?

↳ com.google.android.material.bottomnavigation.BottomNavigationView. Represents a standard bottom navigation bar for application. It is an implementation of material design bottom navigation. Bottom navigation bars make it easy for users to explore and switch between top-level views in a single tap.


1 Answers

set "app:labelVisibilityMode" with "unlabeled"

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:labelVisibilityMode="unlabeled"/>
like image 146
Aaeb Avatar answered Sep 25 '22 15:09

Aaeb