# CollapsingToolbarLayoutKt

Added in 2.4.0

*** ** * ** ***


```
public final class CollapsingToolbarLayoutKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/CollapsingToolbarLayoutKt#(com.google.android.material.appbar.CollapsingToolbarLayout).setupWithNavController(androidx.appcompat.widget.Toolbar,androidx.navigation.NavController,androidx.navigation.ui.AppBarConfiguration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration )` Sets up a `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html` and `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/CollapsingToolbarLayoutKt#(com.google.android.material.appbar.CollapsingToolbarLayout).setupWithNavController(androidx.appcompat.widget.Toolbar,androidx.navigation.NavController,androidx.drawerlayout.widget.DrawerLayout)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout drawerLayout )` Sets up a `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html` and `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |

## Public methods

### setupWithNavController

Artifact: [androidx.navigation:navigation-ui](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/ui/CollapsingToolbarLayout.kt+function:setupWithNavController) Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

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

Sets up a `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html` and `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`.

By calling this method, the title in the Toolbar will automatically be updated when the destination changes (assuming there is a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#label()`).

The `https://developer.android.com/reference/androidx/navigation/ui/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 `https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()` when the navigation icon is clicked.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar` | The Toolbar that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController whose navigation actions will be reflected in the title of the Toolbar. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration` | Additional configuration options for customizing the behavior of the Toolbar |

### setupWithNavController

Artifact: [androidx.navigation:navigation-ui](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/ui/CollapsingToolbarLayout.kt+function:setupWithNavController) Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

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

Sets up a `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.html` and `https://developer.android.com/reference/androidx/appcompat/widget/Toolbar` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`.

By calling this method, the title in the Toolbar will automatically be updated when the destination changes (assuming there is a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#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 `https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()` when the Navigation button is clicked.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/widget/Toolbar toolbar` | The Toolbar that should be kept in sync with changes to the NavController. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController whose navigation actions will be reflected in the title of the Toolbar. |
| `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout drawerLayout` | The DrawerLayout that should be toggled from the Navigation button |