CollapsingToolbarLayoutKt

Added in 1.0.0

public final class CollapsingToolbarLayoutKt


Summary

Public methods

static final void
setupWithNavController(
    @NonNull CollapsingToolbarLayout receiver,
    @NonNull Toolbar toolbar,
    @NonNull NavController navController,
    @NonNull AppBarConfiguration configuration
)

Sets up a CollapsingToolbarLayout and Toolbar for use with a NavController.

static final void
setupWithNavController(
    @NonNull CollapsingToolbarLayout receiver,
    @NonNull Toolbar toolbar,
    @NonNull NavController navController,
    DrawerLayout drawerLayout
)

Sets up a CollapsingToolbarLayout and Toolbar for use with a NavController.

Public methods

setupWithNavController

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

Sets up a CollapsingToolbarLayout and 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 Toolbar toolbar

The Toolbar that should be kept in sync with changes to the NavController.

@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

setupWithNavController

public static final void setupWithNavController(
    @NonNull CollapsingToolbarLayout receiver,
    @NonNull Toolbar toolbar,
    @NonNull NavController navController,
    DrawerLayout drawerLayout
)

Sets up a CollapsingToolbarLayout and 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 button is clicked.

Parameters
@NonNull Toolbar toolbar

The Toolbar that should be kept in sync with changes to the NavController.

@NonNull NavController navController

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

DrawerLayout drawerLayout

The DrawerLayout that should be toggled from the Navigation button