Skip to content

Instantly share code, notes, and snippets.

@sriramrudraraju
Last active October 14, 2021 16:16
Show Gist options
  • Save sriramrudraraju/6ed3ca4480d1ceb4a2329b6ab456ea27 to your computer and use it in GitHub Desktop.
Save sriramrudraraju/6ed3ca4480d1ceb4a2329b6ab456ea27 to your computer and use it in GitHub Desktop.
NavOptions Programatically Android Kotlin
  • Adding to above official documentation, we can also pass popUpto params in navOptionsBuilder
navController.navigate(
  R.id.action_fragmentOne_to_fragmentTwo,     // Destination Id
  null,                                       // Arguments that needs to be passed to destination
  navOptions {
      anim {                                  // Animation options
          enter = android.R.animator.fade_in
          exit = android.R.animator.fade_out
      }
      popUpTo(R.id.fragmentOne) {             // Pop all navigation stack back to fragmentOne
          inclusive = false                   // Don't pop fragmentOne from stack
      }
  }
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment