In according to the documentation, animation for navigation is tracked by this issue.
As you can see in the last comment, the animation API for navigation is currently provided by the respective accompanist library. But, in the future it will be moved back to the standard navigation library. So, for now, I suggest you to use the Accompanist library instead of the "default" one.
If you're doing that already, you can replace the animation using something like this:
AnimatedNavHost(
navController = navController,
startDestination = ROUTE_MAIN,
enterTransition = {
if (initialState.destination.route == ROUTE_MAIN) {
EnterTransition.None
} else {
slideInHorizontally(
initialOffsetX = { it },
animationSpec = tween(300)
)
}
},
exitTransition = {
if (initialState.destination.route == ROUTE_MAIN) {
ExitTransition.None
} else {
slideOutHorizontally(
targetOffsetX = { -it },
animationSpec = tween(300)
)
}
},
popEnterTransition = {
if (targetState.destination.route == ROUTE_MAIN) {
EnterTransition.None
} else {
slideInHorizontally(
initialOffsetX = { -it },
animationSpec = tween(300)
)
}
},
popExitTransition = {
if (targetState.destination.route == ROUTE_MAIN) {
ExitTransition.None
} else {
slideOutHorizontally(
targetOffsetX = { it },
animationSpec = tween(300)
)
}
},
) {
composable(ROUTE_MAIN) { ... }
composable(ROUTE_DETAILS) { ... }
...
}
As you can see in the sample above, I'm disabling the animation from the ROUTE_MAIN
using the EnterTransition.None
and ExitTransition.None
based on the current route (initialState.destination.route
) and the target route (targetState.destination.route
).