How to dynamically hide a menu item in BottomNavigationView?

You can hide a menu item by setting isVisible as false with using suggested property isVisible in Kotlin. But this makes your menu item removed from BottomNavigationView on Android 9 as my observation.

bottomNavigation.menu.findItem(R.id.menu_item).isVisible = false

If you use a single color for your bottom navigation view's background you can use similar approach to save the menu items in place. As an example the one in the right edge.

// 0x000000 is black as an example
bottomNavigation.menu.findItem(R.id.menu_item).icon = ColorDrawable(0x000000)
// and disable for the actions
bottomNavigation.menu.findItem(R.id.menu_item).isEnabled = false

mBottomNavigationView.getMenu().removeItem(R.id.item_name);

removeItem does the trick. Not sure why setVisible method is not working.