setupNavigation

@JvmName(name = "setup")
fun NavDrawerLayout.setupNavigation(drawerNavigationView: DrawerNavigationView, navHostFragment: NavHostFragment, configuration: AppBarConfiguration = AppBarConfiguration(drawerNavigationView.getDrawerMenu(), this), @FloatRange(from = 0.0, to = 1.0) toolbarBackThreshold: Float = 0.75f)(source)

Sets up navigation for NavDrawerLayout with a DrawerNavigationView and NavHostFragment. Supports both XML and programmatically created navigation graphs (NavGraphBuilder DSL).

Parameters

drawerNavigationView

The DrawerNavigationView containing the navigation menu to be linked with navigation actions.

navHostFragment

The NavHostFragment that hosts the navigation graph and manages navigation transactions.

configuration

Optional AppBarConfiguration to customize top-level destinations and drawer behavior. By default, uses the menu from drawerNavigationView and this NavDrawerLayout as the drawer layout.

toolbarBackThreshold

The threshold (from 0.0 to 1.0) at which the NavDrawerLayout toolbar switches its title, subtitle and navigation icon to those of the back destination during predictive back animation progress. Defaults to 0.75f.

By default, the back stack will be popped back to the navigation graph's start destination except for Activity and FloatingWindow destinations and for menu items that have android:menuCategory="secondary".

Usage example:

navDrawerLayout.setupNavigation(drawerNavigationView, navHostFragment)

See also


@JvmName(name = "setupDsl")
fun NavDrawerLayout.setupNavigation(drawerNavigationView: DrawerNavigationView, navHostFragment: NavHostFragment, startDestination: KClass<*>, route: KClass<*>? = null, configuration: AppBarConfiguration = AppBarConfiguration(drawerNavigationView.getDrawerMenu(), this), @FloatRange(from = 0.0, to = 1.0) toolbarBackThreshold: Float = 0.75f, builder: NavGraphBuilder.() -> Unit)(source)

Overload for programmatic navigation graph creation using NavGraphBuilder DSL.

Example usage:

navDrawerLayout.setupNavigation(
drawerNavigationView,
navHostFragment,
startDestination = "widgets_dest"
) {
mainNavGraph()
}

@JvmName(name = "setup")
fun <T : ToolbarLayout> T.setupNavigation(bottomTabLayout: BottomTabLayout, navHostFragment: NavHostFragment, configuration: AppBarConfiguration = AppBarConfiguration(bottomTabLayout.menu, null), @FloatRange(from = 0.0, to = 1.0) toolbarBackThreshold: Float = 0.75f)(source)

Sets up navigation for ToolbarLayout with a BottomTabLayout and NavHostFragment. Supports both XML and programmatically created navigation graphs (NavGraphBuilder DSL).

Parameters

bottomTabLayout

The BottomTabLayout to be linked with navigation actions.

navHostFragment

The NavHostFragment that hosts the navigation graph and manages navigation transactions.

configuration

Optional AppBarConfiguration to customize top-level destinations and drawer behavior. By default, uses the menu from the bottomTabLayout.

toolbarBackThreshold

The threshold (from 0.0 to 1.0) at which the ToolbarLayout toolbar switches its title, subtitle and navigation icon to those of the back destination during predictive back animation progress. Defaults to 0.75f.

By default, the back stack will be popped back to the navigation graph's start destination except for Activity and FloatingWindow destinations and for menu items that have android:menuCategory="secondary".

Usage example:

toolbarLayout.setupNavigation(bottomTabLayout, navHostFragment)

See also


@JvmName(name = "setupDsl")
fun <T : ToolbarLayout> T.setupNavigation(bottomTabLayout: BottomTabLayout, navHostFragment: NavHostFragment, startDestination: KClass<*>, route: KClass<*>? = null, configuration: AppBarConfiguration = AppBarConfiguration(bottomTabLayout.menu, null), @FloatRange(from = 0.0, to = 1.0) toolbarBackThreshold: Float = 0.75f, builder: NavGraphBuilder.() -> Unit)(source)

Overload for programmatic navigation graph creation using NavGraphBuilder DSL.

Example usage:

toolbarLayout.setupNavigation(
bottomTabLayout,
navHostFragment,
startDestination = "widgets_dest"
) {
mainNavGraph()
}