Questions related to bottom navigation bar. Bottom Navigation Bar menu item title,icon,populating content and and enabled states related issues. Bottom navigation bar item click listener, item background resource,item text color, inflate menu,max item count. Bottom Navigation Bar is an implementation of material design bottom navigation.
BottomNavigationView
BottomNavigationView Represents a standard bottom navigation bar for application. It is an implementation of material design bottom navigation.
Bottom navigation bars make it easy for users to explore and switch between top-level views in a single tap. It should be used when application has three to five top-level destinations.
The bar contents can be populated by specifying a menu resource file. Each menu item title, icon and enabled state will be used for displaying bottom navigation bar items. Menu items can also be used for programmatically selecting which destination is currently active.
This widget has a couple of attributes set on it. We can use these to set menu items we wish to display and the colours to be used throughout the Bottom Navigation View:
app:itemBackground
— The background color to be used for the bottom navigation menuapp:itemIconTint
— The tint to be used for the icons in the bottom navigation menuapp:itemTextColor
— The color to be used for the text in the bottom navigation menuapp:menu
— The menu resource to be used to display items in the bottom navigation menu
We can also set these values programmatically by using the following methods on our BottomNavigationView instance:
inflateMenu(int menuResource)
— Inflate a menu for the bottom navigation view using a menu resource identifier.setItemBackgroundResource(int backgroundResource)
— The background to be used for the menu items.setItemTextColor(ColorStateList colorStateList)
— A ColorStateList used to color the text used for the menu itemssetItemIconTintList(ColorStateList colorStateList)
— A ColorStateList used to tint the icons used for the menu items