Karim Rak.
Karim Rak.

Reputation: 13

How to remove the title of BottomnavigationView when item is selected? // Android

I created a BottomNavigationView. So far so well. Problem: When I select the last item, the title cuts of, because of its length, so I decided to remove the text when the user clicks on the items of the NavigationView.

This is what it looks like now

enter image description here

I want the Icon to be bigger and text to be removed when it is selected

But I do not know how?

activity_main.xml:

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottom_navigation"
    style="@style/Widget.Design.BottomNavigationView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom"
    android:background="@color/transparent"
    android:backgroundTint="@color/colorPrimary"
    app:hideOnScroll="true"
    app:labelVisibilityMode="labeled"
    app:layout_scrollFlags="scroll|enterAlways"
    app:menu="@menu/bottom_app_bar_left" />

the menu.xml:

<menu xmlns:android="http://schemas.android.com/apk/res/android">



<item
    android:id="@+id/nav_info"
    android:icon="@drawable/ic_baseline_info_24px"
    android:title="@string/nav_info" />

<item
    android:id="@+id/nav_vehicle"
    android:icon="@drawable/ic_baseline_tram_24px"
    android:title="@string/nav_vehicle"/>

<item
    android:id="@+id/nav_emptyspace"
    android:title=""
    android:enabled="false"/>



<item
    android:id="@+id/nav_computer"
    android:icon="@drawable/ic_baseline_computer_24px"
    android:title="@string/nav_computer"/>

<item
    android:id="@+id/nav_favorites"
    android:icon="@drawable/ic_grade_black_24dp"
    android:title="@string/nav_favorites"/>

Upvotes: 1

Views: 201

Answers (1)

Manoj Perumarath
Manoj Perumarath

Reputation: 10214

Change the property to

app:labelVisibilityMode="unlabeled"

Icons will be there

Upvotes: 1

Related Questions