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 u...

问题:

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"/>


回答1:

Change the property to

app:labelVisibilityMode="unlabeled"

Icons will be there

  • 发表于 2019-03-31 02:14
  • 阅读 ( 198 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除