Builder

class Builder
kotlin.Any
   ↳ androidx.navigation.NavOptions.Builder

Builder for constructing new instances of NavOptions.

Summary

Public constructors

Public methods
NavOptions.Builder
setPopUpTo(@IdRes destinationId: Int, inclusive: Boolean)

Pop up to a given destination before navigating.

NavOptions.Builder

Launch a navigation target as single-top if you are making a lateral navigation between instances of the same target (e.g. detail pages about similar data items) that should not preserve history.

NavOptions.Builder
setPopExitAnim(@AnimRes @AnimatorRes popExitAnim: Int)

Sets a custom Animation or Animator resource for the exit animation when popping off the back stack.

NavOptions.Builder
setPopEnterAnim(@AnimRes @AnimatorRes popEnterAnim: Int)

Sets a custom Animation or Animator resource for the enter animation when popping off the back stack.

NavOptions.Builder
setExitAnim(@AnimRes @AnimatorRes exitAnim: Int)

Sets a custom Animation or Animator resource for the exit animation.

NavOptions.Builder
setEnterAnim(@AnimRes @AnimatorRes enterAnim: Int)

Sets a custom Animation or Animator resource for the enter animation.

NavOptions

Public constructors

<init>

Builder()

Public methods

setPopUpTo

@NonNull fun setPopUpTo(@IdRes destinationId: Int, inclusive: Boolean): NavOptions.Builder

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

Parameters
destinationId Int: The destination to pop up to, clearing all intervening destinations.
inclusive Int: true to also pop the given destination from the back stack.
Return
NavOptions.Builder: this Builder

setLaunchSingleTop

@NonNull fun setLaunchSingleTop(singleTop: Boolean): NavOptions.Builder

Launch a navigation target as single-top if you are making a lateral navigation between instances of the same target (e.g. detail pages about similar data items) that should not preserve history.

Parameters
singleTop Boolean: true to launch as single-top

setPopExitAnim

@NonNull fun setPopExitAnim(@AnimRes @AnimatorRes popExitAnim: Int): NavOptions.Builder

Sets a custom Animation or Animator resource for the exit animation when popping off the back stack.

Note: Animator resources are not supported for navigating to a new Activity

Parameters
popExitAnim Int: Custom animation to run
Return
NavOptions.Builder: this Builder

setPopEnterAnim

@NonNull fun setPopEnterAnim(@AnimRes @AnimatorRes popEnterAnim: Int): NavOptions.Builder

Sets a custom Animation or Animator resource for the enter animation when popping off the back stack.

Note: Animator resources are not supported for navigating to a new Activity

Parameters
popEnterAnim Int: Custom animation to run
Return
NavOptions.Builder: this Builder

setExitAnim

@NonNull fun setExitAnim(@AnimRes @AnimatorRes exitAnim: Int): NavOptions.Builder

Sets a custom Animation or Animator resource for the exit animation.

Note: Animator resources are not supported for navigating to a new Activity

Parameters
exitAnim Int: Custom animation to run
Return
NavOptions.Builder: this Builder

setEnterAnim

@NonNull fun setEnterAnim(@AnimRes @AnimatorRes enterAnim: Int): NavOptions.Builder

Sets a custom Animation or Animator resource for the enter animation.

Note: Animator resources are not supported for navigating to a new Activity

Parameters
enterAnim Int: Custom animation to run
Return
NavOptions.Builder: this Builder

build

@NonNull fun build(): NavOptions
Return
NavOptions: a constructed NavOptions