代码之家  ›  专栏  ›  技术社区  ›  grrrrrr

如何将BottomNavigationBar设置为菜单项之间的间距相等?

  •  0
  • grrrrrr  · 技术社区  · 6 年前

    我有一个android应用程序,在横向模式下有一个底部导航栏,有四个菜单项。这些物品被捆在中间,就像这样:

    bunched items

    我希望它们均匀地分布在导航栏上,如下所示:

    evenly spaced items

    如何完成此格式设置?

    上面的示例图片来自 material.io 文件

    我的xml:

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="0dp"
        android:layout_marginStart="0dp"
        android:background="?android:attr/windowBackground"
        android:layout_alignParentBottom="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/navigation"
        app:labelVisibilityMode="labeled" />
    

    我希望我的图标分布在整个栏上,包括用红色标注的空间:

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  0
  •   forpas    6 年前

    为BottomNavigationView设置此属性:

    app:labelVisibilityMode="labeled"