I\'ve created a small app that has three fragments for top-level navigation through a BottomNavigationView. If you launch the app and click on a navigation button on the bottom
Starting with 1.0.0-alpha07 you can use AppBarConfiguration
to configure that behaviour.
AppBarConfiguration
has a Builder constructor so you can create a new Builder
with a specific set of top level destinations, referenced by their id
(this id
is the one you set on your navigation layout).
Create new AppBarConfiguration
:
val appBarConfiguration = AppBarConfiguration
.Builder(
R.id.navigationHomeFragment,
R.id.navigationListFragment,
R.id.navigationProfileFragment)
.build()
Then, instead of setupActionBarWithNavController(this, navController)
you need to call setupActionBarWithNavController(this, navController, appBarConfiguration)
This is the right way to handle top navigation behaviours.