Questions tagged [bottomnavigationview]

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.


                                         BottomNavigationView

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 menu
  • app:itemIconTint — The tint to be used for the icons in the bottom navigation menu
  • app:itemTextColor — The color to be used for the text in the bottom navigation menu
  • app: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 items
  • setItemIconTintList(ColorStateList colorStateList) — A ColorStateList used to tint the icons used for the menu items

Useful Links:

1718 questions
45
votes
14 answers

BottomNavigationView - How to avoid recreation of Fragments and reuse them

I would like to make a bottom navigation bar in my project. Every view has it's own fragment. The problem is that every time i click on the button to change the view for example from recents to favorites it creates new fragment with completely new…
42
votes
9 answers

How to dynamically hide a menu item in BottomNavigationView?

I want to hide a menu item of BottomNavigationView dynamically based on some conditions. I tried the following but it is not working. mBottomNavigationView.getMenu() .findItem(R.id.item_name) …
Ram
  • 1,474
  • 1
  • 10
  • 17
41
votes
1 answer

Cannot resolve method 'setShiftingMode(Boolean)' in BottomNavigationView

After upgrading to latest support library '28.0.0-alpha1' I cannot disable shifting mode in my BottomNavigationView i.e. the BottomNavigationItemView.setShiftingMode() method is no longer available. java.lang.NoSuchFieldException: No field…
Darush
  • 11,403
  • 9
  • 62
  • 60
41
votes
14 answers

How to remove icon animation for bottom navigation view in android

I have implemented Bottom Navigation View from Design Support Library 25 in my project. I have 5 icons in the view. whenever an icon is selected it's having some animation. But when 3 or fewer icons is not showing any animations. I want to remove…
Nabeel K
  • 5,938
  • 11
  • 38
  • 68
39
votes
6 answers

How to combine BottomAppBar + FAB with BottomNavigationView

I want to use the FloatingActionButton, along with its behaviour when anchored on a BottomAppBar, on top of a BottomNavigationView. I came up with a rather "hacky" trick to just place the BottomNavigationView on top of the BottomAppBar without…
39
votes
5 answers

Background color change in BottomNavigationView

I have implemented BottomNavigationView which is available from the new support library 25.0.0. Here is my code for that
Ravi
  • 34,851
  • 21
  • 122
  • 183
38
votes
14 answers

How to Set selected item in BottomNavigationView

I am trying to set default item on activity created but it isn't working? This is my code: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_userhome); mTextMessage…
Abhijeet
  • 481
  • 1
  • 6
  • 14
34
votes
7 answers

How to change android jetpack compose bottomAppBar icon tint color?

BottomNavigationBar() can only take the background and contentColor but there is no option for tint color.
34
votes
22 answers

How to handle bottom navigation perfectly with back pressed

I am working on a bottom navigation bar, but I am not getting perfectly bottom navigation bar. My MainActivity class: public class MainActivity extends AppCompatActivity { private static final String SELECTED_ITEM = "selected_item"; …
33
votes
1 answer

Remove Animation/Shifting mode from BottomNavigationView android

i am building an application in which i have a BottomNavigationView. Everything works fine until i get to the Activity. The Navigation is this: The problem is that it has this default animation so it pushes the active element everytime higher than…
user7157256
29
votes
3 answers

How can I add a menu dynamically to bottom navigation view?

Android has new ui element - BottomNavigationView I don't want to contain my menus in the xml files. I will receive the information about menu items and order from backend side. I want to create them dynamically and set into the…
Kiryl Bielašeŭski
  • 2,663
  • 2
  • 28
  • 40
28
votes
3 answers

Can't remove space on top of nav_host_fragment

I just implemented a bottom navigation (AS's default - File -> New -> Activity -> Bottom Navigation Activity) Everything is fine except for a space on the top of the nav_host_fragment. Since it was generated in a ConstraintLayout, I tried to clean…
28
votes
2 answers

Inflate Bottom Navigation View menu programmatically

Bottom Navigation View has been added to version 25 of the Design Support Library. Tried and it's much easier to use now. But I am facing problem implementing it as per my app requirements. I want to inflate menu resource dynamically and change…
Priya Mall
  • 581
  • 1
  • 10
  • 22
28
votes
11 answers

BottomNavigationView - How to uncheck all MenuItems and keep Titles being displayed?

As I liked the design from BottomNavigationView I decided to implement a new Menu for my App with it, instead of just using simple buttons. I took this post as a guideline. According to BottomNavigationView's documentation, its purpose is to…
Victor Oliveira
  • 3,293
  • 7
  • 47
  • 77
26
votes
11 answers

How to implement bottom navigation tab as per the google new guideline

How to implement bottom navigation tab as per the google new guideline (Pure android). Is there any example.? Ref: https://www.google.com/design/spec/components/bottom-navigation.html