CodePudding user response:
This can be easily done by subscribing to navigation component destination change listener, like this:
navController.addOnDestinationChangedListener { controller, destination, arguments ->
if(destination.id = R.id.yourMainFragment) {
// TODO hide/show your view here
}
}
And then hiding/showing based on destination