I would like to have a behavior similar to YouTube:
- have a toolbar and bottom tabs
- going to "Library" (5th tab), the up button doesn't appear
- going inside "My Videos", the up button appears
Here are my constraints:
- use jetpack navigation
- use a
Toolbar(inside anAppBarLayoutif that matters) - have bottom tabs (
BottomNavigationView) - all bottom tabs are "top level" in the sense where they don't change the
Toolbarup button - other application screens are not "top level" and should have an up arrow
- one of the tabs is the navigation graph's default destination
By default, when all is implemented, the navigation is handled automatically by the Jetpack Navigation library. I hook the toolbar with the navigation controller using this helper:
NavigationUI.setupWithNavController(main_toolbar, navController)
This works well, but if I switch one of the bottom tabs, the up button appears and pressing it pops back to the default destination.
This is fine when bottom tabs are not used, but this is awkward when they are.