Android 在BottomNavigationView中未省略标签

Android 在BottomNavigationView中未省略标签,android,bottomnavigationview,Android,Bottomnavigationview,我有一个带有BottomNavigationView的布局,属性app:labelVisibilityMode设置为标签: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layou

我有一个带有
BottomNavigationView
的布局,属性
app:labelVisibilityMode
设置为
标签

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:labelVisibilityMode="labeled"
        app:menu="@menu/navigation" />

</FrameLayout>

使标签稍微短一点会导致正确的行为:


有没有办法处理较长的标签?最好的解决方案是将其省略号化,并在没有空间容纳整个文本时显示“更长的文本…”。

我也有同样的问题,搜索了很多次。最后,我在代码中添加了一个解决方案。 只需在代码中添加以下行

 BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigation.getChildAt(0);
    for (int i = 0; i < menuView.getChildCount(); i++) {
        BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
        View activeLabel = item.findViewById(R.id.largeLabel);
        if (activeLabel instanceof TextView) {
            activeLabel.setPadding(0, 0, 0, 0);
        }
    }
BottomNavigationMenuView menuView=(BottomNavigationMenuView)navigation.getChildAt(0);
对于(int i=0;i


试试这个

这个解决方案还帮助我解决了菜单项不太合适的问题。未选中时显示为ok,但选中时缩小。谢谢
 BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigation.getChildAt(0);
    for (int i = 0; i < menuView.getChildCount(); i++) {
        BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
        View activeLabel = item.findViewById(R.id.largeLabel);
        if (activeLabel instanceof TextView) {
            activeLabel.setPadding(0, 0, 0, 0);
        }
    }
 <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|start"
        app:itemIconTint="@color/color_c3c3c3"
        app:itemTextColor="@color/color_aaaaaa"
        android:textSize="@dimen/_13sdp"
        app:menu="@menu/nav_bottom" />