如何设置底部导航栏菜单项之间的等距?

3
我有一个安卓应用,在横屏模式下有一个底部导航栏,包含四个菜单项。这些菜单项在中间挤在一起,如下所示:

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

2个回答

0

你必须使用

 android:fitsSystemWindows="true"

这段代码不起作用。 - tej shah

0

为BottomNavigationView设置此属性:

app:labelVisibilityMode="labeled"

你知道有没有 com.google.android.material 的替代方案来解决 com.android.support:design 的问题吗?看起来 support:design 库不包含这个 xml 属性 https://developer.android.com/reference/android/support/design/widget/BottomNavigationView - grrrrrr
这个属性是用于 android.support.design.widget.BottomNavigationView - forpas
1
我的理解是,Material Components库的存在是为了让您实现material.io设计文档中所展示的内容。支持设计库在这一点上已经过时了几代。 - Ben P.
@forpas,android.support.design.widget.BottomNavigationView文档中仅显示了以下XML属性:BottomNavigationView_itemBackgroundBottomNavigationView_itemIconTintBottomNavigationView_itemTextColor - grrrrrr
我之前使用的是27.1.1版本,刚刚更新到了28.0.0版本——添加app:labelVisibilityMode="labeled"对布局没有任何影响。 - grrrrrr
显示剩余10条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接