我试图在底部导航视图中添加超过 5 个项目,但它导致膨胀错误。
According to Google's Material Design specification, BottomNavigationView does not support more than 5 items. You can use another library for BottomNavigationView since you can't achieve this with Google's library.
Create a menu resource with up to 5 navigation targets (BottomNavigationView does not support more than 5 items).
https://material.io/develop/android/components/bottom-navigation-view/
Secondly, Having 5 or more items in BottomNavigation is a bad design in terms of User Experience. Even 4 is a stretch. If you need more than 5 items, BottomNavigation is not suitable for you.
According to Material Design Specification, it is a bad practice to use more than 5 menu
items for BottomNavigationView
. Since, it is used to show only 3 to 5 top-level destinations(not related to same subject but of equal importance) , I suggest you to use Navigation Drawer
instead. Also, I would only recommend you to use Tab Layout with ViewPager
, if the destinations are connected to a common subject.
To illustrate it further, let's assume there is a Pill Reminder
app. The related destinations can be Pending
, Completed
and/or Missed
which are related in a way that they all show status of all Reminder
at a point of time. To show these information, I would use ViewPager with TabLayout
.
For other destinations such as Settings
, Nearby Pharmacies
, etc. which are top-level, I would use NavigationDrawer
.
如果你想要,那么你可以采用水平线性布局,采用水平滚动,然后采用你喜欢的文本视图或按钮。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.