Search code examples
androidandroid-fragmentsandroid-architecture-navigation

Remove bottom Navigation when navigate to new Fragment


i have bottom Navigation, i navigate new Fragment from bottom click but Bottom Navigation is not removed to the new fragment

navigate new fragment

edit_flow.setOnClickListener {

            findNavController().navigate(R.id.action_navigation_home_to_flowFragment)

}

i want to remove the bottom Navigation when launching FlowFragment

see the image


Solution

  • on the Host Activity, after bind NavControler, Try this:

     navController.addOnDestinationChangedListener { _, destination, _ ->
            when (destination.id) {
                R.id.yourFragment-> bottomNavigationMain.visibility = View.GONE
                    .
                    .
                    .
                else -> bottomNavigationMain.visibility = View.VISIBLE
            }
        }
    

    in here. yourFragment should not show ButtonNavigationMenu. the other fragments will have it visible.