【问题标题】:BottomNavigationView, icons spaced equallyBottomNavigationView,图标等间距
【发布时间】:2022-07-03 22:24:18
【问题描述】:

我正在使用带有两个项目的 BottomNavigationView,但是,在平板电脑或横向上,它将两个图标都推到了中心。

我正在尝试与材料显示的相同间隔,但没有标签:

这是我的代码,有人知道是否有一个属性可以用来实现吗?

<com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottom_nav_view"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@color/navigation_background"
            app:itemIconTint="@color/navigation_icon_color_selector"
            app:labelVisibilityMode="unlabeled"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:menu="@menu/bottom_nav_menu" />

【问题讨论】:

  • 在两个项目之间的菜单中添加一个虚拟项目
  • 它仍然不会均匀分布

标签: android xml kotlin material-ui bottomnavigationview


【解决方案1】:

将每个项目的宽度设置为0dp,并将这条线添加到每个项目上以均匀分布项目

android:layout_weight="1"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-19
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多