I'm using the following sippet of code to navigate from a composable to another one, but it has a default fade animation. How can I remove it? I tried using an empty anim resource but it doesn't work.
navHostController.navigate(
"destination_route",
navOptions {
popUpTo("this_route") {
inclusive = true
}
anim {
enter = R.anim.empty_animation
exit = R.anim.empty_animation
popEnter = R.anim.empty_animation
popExit = R.anim.empty_animation
}
}
)
R.anim.empty_animation:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--Empty to disable animation-->
</set>
if you use version navigation-compose:2.7.5 or above, you need to add enterTransition and exitTransition in NavHost.
NavHost(navController = rememberNavigationBarController,
startDestination = "home",
modifier = Modifier.padding(it),
enterTransition = {
// you can change whatever you want transition
EnterTransition.None
},
exitTransition = {
// you can change whatever you want transition
ExitTransition.None
}) {
composable("home") {}
composable("cinema") {}
composable("ticket") { }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With