I am trying to add more then 5 items in bottom navigation view but its causing inflate error.
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.
Having 5 or more items in BottomNavigation is a bad design in terms of User Experience. Even 4 is a stretch.
— This answer seems awfully dogmatic without providing heuristics, evidence, or proof. What is bad about, e.g., this AirBnB screen? –
Bulbiferous 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
.
If you want that then u can take a Horizontal linear layout in that take the horizontal scroll and then take textview or button as much u like.
Currently (2023), you can have more than 5 items in bottom navigation view as explained here (emphasis mine):
We have design concerns around allowing more items than 5. If you really need that, you can extend BottomNavigationView and override getMaxItemCount() to provide a different value than 5.
source: https://github.com/material-components/material-components-android/issues/543#issuecomment-881579335
BUT take into account that it will only work from version 1.8.0 and up
source: https://github.com/material-components/material-components-android/pull/2923
© 2022 - 2024 — McMap. All rights reserved.