I will be glad to finally get a help for this. I have a single activity application. One of the fragments is also a nav_host(say nav_host2) to other fragments for its bottom navigation.
I want to exit from the from fragment in nav_host two to nav_host1 using deep-linking but notice that the bottom navigation on nav_host2 show on nav_host1 which I do not want as seen in the diagram below.
How can I exit the nav_host2 without having the bottom navigation show even-though it is null
use addOnDestinationChangedListener
and hide and show bottomNavigation
with respect to destinationId
private val AUTH_NAV_GRAPH = arrayOf(
R.id.destination_splash,
R.id.destination_login,
R.id.destination_register,
R.id.destination_forgetpassword
)
val navController = findNavController(this,R.id.nav_host_fragment)// this maybe change
navController.addOnDestinationChangedListener { controller, destination, arguments ->
if(destination.id in AUTH_NAV_GRAPH) {
bottomNavigation?.visibility=View.GONE
} else {
bottomNavigation?.visibility=View.VISIBLE
}
}
where AUTH_NAV_GRAPH
are like fragments with no bottomNavigation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.