You should create the drawer in your activity and than handle it's visibility in addOnDestinationChangedListener
:
navController.addOnDestinationChangedListener { _, destination, _ ->
if (destination.id == R.id.someFragment) {
toolbar.visibility = View.GONE
drawer_layout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
} else {
toolbar.visibility = View.VISIBLE
drawer_layout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
}
}
Don't do this in fragments, it's not a good pattern not that it doesn't compile or something.
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.