AppBarConfiguration


public final class AppBarConfiguration


Configuration options for NavigationUI methods that interact with implementations of the app bar pattern such as androidx.appcompat.widget.Toolbar, com.google.android.material.appbar.CollapsingToolbarLayout, and androidx.appcompat.app.ActionBar.

Summary

Nested types

public final class AppBarConfiguration.Builder

The Builder class for constructing new AppBarConfiguration instances.

Interface for providing custom 'up' behavior beyond what is provided by androidx.navigation.NavController.navigateUp.

Public methods

final DrawerLayout

This method is deprecated. Use {@link #getOpenableLayout()}.

final AppBarConfiguration.OnNavigateUpListener

The OnNavigateUpListener that should be invoked if androidx.navigation.NavController.navigateUp returns false.

final Openable

The Openable layout indicating that the Navigation button should be displayed as a drawer symbol when it is not being shown as an Up button.

final @NonNull Set<@NonNull Integer>

The set of destinations by id considered at the top level of your information hierarchy.

final boolean

Determines whether a NavDestination is a top level destination in AppBarConfiguration.

Public methods

getDrawerLayout

Added in 1.0.0
Deprecated in 2.3.0
public final DrawerLayout getDrawerLayout()

The DrawerLayout indicating that the Navigation button should be displayed as a drawer symbol when it is not being shown as an Up button.

Returns
DrawerLayout

The DrawerLayout that should be toggled from the Navigation button

getFallbackOnNavigateUpListener

Added in 1.0.0
public final AppBarConfiguration.OnNavigateUpListener getFallbackOnNavigateUpListener()

The OnNavigateUpListener that should be invoked if androidx.navigation.NavController.navigateUp returns false.

Returns
AppBarConfiguration.OnNavigateUpListener

a OnNavigateUpListener for providing custom up navigation logic, if one was set.

getOpenableLayout

Added in 2.3.0
public final Openable getOpenableLayout()

The Openable layout indicating that the Navigation button should be displayed as a drawer symbol when it is not being shown as an Up button.

Returns
Openable

The Openable layout that should be toggled from the Navigation button

getTopLevelDestinations

Added in 1.0.0
public final @NonNull Set<@NonNull IntegergetTopLevelDestinations()

The set of destinations by id considered at the top level of your information hierarchy. The Up button will not be displayed when on these destinations.

Returns
@NonNull Set<@NonNull Integer>

The set of top level destinations by id.

isTopLevelDestination

Added in 2.6.0
public final boolean isTopLevelDestination(@NonNull NavDestination destination)

Determines whether a NavDestination is a top level destination in AppBarConfiguration.

Returns true if the NavDestination was added directly as a top level destination via AppBarConfiguration.Builder constructors such as AppBarConfiguration.Builder(topLevelDestinationIds: Set<Int>). If destination was added with a AppBarConfiguration.Builder that could take in a graph, i.e. AppBarConfiguration.Builder(NavGraph) orAppBarConfiguration.Builder(Menu), this helper will return true if the destination is the start destination of a graph (including nested graphs i.e. MenuItem that are also NavGraph), or an individual MenuItem within the Menu.

Parameters
@NonNull NavDestination destination

the NavDestination to check whether it is a topLevelDestination