ToolbarKt

public final class ToolbarKt


Summary

Public methods

static final void
ToolbarKt.setupWithNavController(
    @NonNull Toolbar receiver,
    @NonNull NavController navController,
    @Nullable DrawerLayout drawerLayout
)

Sets up a Toolbar for use with a NavController.

static final void
ToolbarKt.setupWithNavController(
    @NonNull Toolbar receiver,
    @NonNull NavController navController,
    @NonNull AppBarConfiguration configuration
)

Sets up a Toolbar for use with a NavController.

Public methods

ToolbarKt.setupWithNavController

@NonNull
public static final void ToolbarKt.setupWithNavController(
    @NonNull Toolbar receiver,
    @NonNull NavController navController,
    @Nullable DrawerLayout drawerLayout
)

Sets up a Toolbar for use with a NavController.

By calling this method, the title in the Toolbar will automatically be updated when the destination changes (assuming there is a valid label).

The start destination of your navigation graph is considered the only top level destination. On the start destination of your navigation graph, the Toolbar will show the drawer icon if the given drawerLayout is non null. On all other destinations, the Toolbar will show the Up button.

This method will call NavController.navigateUp when the navigation icon is clicked.

Parameters
@NonNull NavController navController

The NavController whose navigation actions will be reflected in the title of the Toolbar.

@Nullable DrawerLayout drawerLayout

The DrawerLayout that should be toggled from the Navigation button

ToolbarKt.setupWithNavController

@NonNull
public static final void ToolbarKt.setupWithNavController(
    @NonNull Toolbar receiver,
    @NonNull NavController navController,
    @NonNull AppBarConfiguration configuration
)

Sets up a Toolbar for use with a NavController.

By calling this method, the title in the Toolbar will automatically be updated when the destination changes (assuming there is a valid label).

The AppBarConfiguration you provide controls how the Navigation button is displayed and what action is triggered when the Navigation button is tapped.

This method will call NavController.navigateUp when the navigation icon is clicked.

Parameters
@NonNull NavController navController

The NavController whose navigation actions will be reflected in the title of the Toolbar.

@NonNull AppBarConfiguration configuration

Additional configuration options for customizing the behavior of the Toolbar