我可以在底部导航视图中添加超过 5 个菜单项吗?

问题描述 投票:0回答:4

我试图在底部导航视图中添加超过 5 个项目,但它会导致膨胀错误。

android bottomnavigationview
4个回答
10
投票

根据Google的Material Design规范,BottomNavigationView不支持超过5个项目。您可以为 BottomNavigationView 使用另一个库,因为您无法使用 Google 的库实现此目的。

创建最多包含 5 个导航目标的菜单资源(BottomNavigationView 不支持超过 5 个项目)。
https://material.io/develop/android/components/bottom-navigation-view/

其次,就用户体验而言,BottomNavigation 中有 5 个或更多项目是一个糟糕的设计。即使是 4 也是一个延伸。如果您需要超过 5 个项目,BottomNavigation 不适合您。


3
投票

根据 Material Design 规范,为

menu
使用超过 5 个
BottomNavigationView
项目是一种不好的做法。由于它仅用于显示 3 到 5 个顶级目的地(与同一主题无关,但重要性相同),我建议您使用
Navigation Drawer
代替。另外,如果目的地与共同主题相关,我只建议您使用
Tab Layout with ViewPager

为了进一步说明,我们假设有一个

Pill Reminder
应用程序。相关目的地可以是
Pending
Completed
和/或
Missed
,它们以在某个时间点都显示所有
Reminder
的状态的方式相关。为了显示这些信息,我会使用
ViewPager with TabLayout

对于其他顶级目的地,例如
Settings
Nearby Pharmacies
等,我会使用
NavigationDrawer


2
投票

如果您想要,那么您可以采用水平线性布局,其中采用水平滚动,然后采用文本视图或按钮,只要您喜欢。


0
投票

目前(2023 年),底部导航视图中可以有超过 5 个项目,如下所述(强调我的):

我们在设计上存在允许超过 5 个项目的问题。如果您 真的需要它,你可以扩展 BottomNavigationView 并覆盖 getMaxItemCount() 提供与 5 不同的值

来源:https://github.com/material-components/material-components-android/issues/543#issuecomment-881579335

但请考虑到它仅适用于 1.8.0 及更高版本

来源:https://github.com/material-components/material-components-android/pull/2923

© www.soinside.com 2019 - 2024. All rights reserved.