Search code examples
androidandroid-fragmentskotlinandroid-bottom-nav-viewandroid-architecture-navigation

Hide android bottom navigation view for child screens/ fragments


I'm trying to create a single activity Android application. I have MainActivity (only activity) with BottomNavigationView, three top level fragments and some child fragments. My requirement is whenever the screen is showing top level fragments, bottom navigation should be visible such that switching is possible. But when I'm viewing any of the child fragments, bottom navigation should be hidden. Is there any out-of-box way using the Navigation component or need to change the visibility manually ?


Solution

  • You have to make a method in MainActivity for visibility. Do call that method from fragments where you want to show or hide.

    One thing I faced with such scenario is, bottom navigation visibility is not being properly gone. So I put bottom navigation view in Relative layout and hide that parent view.