Search code examples
androidandroid-jetpack-compose

Disable NavHost animation


Is there any option to disable the CrossFade animation when navigating in Jetpack Compose?

In the source code, I see that the CrossFade is simply hardcoded, and in AnimatedNavHost from "accompanist" I can't locate such an option.


Solution

  • After digging i found the following solution:

    In the AnimatedNavHost composable, we need to specify 'empty' transitions.

     AnimatedNavHost(
                        navController = navController,
                        startDestination = "main",
                        enterTransition = { _, _ -> EnterTransition.None},
                        exitTransition = { _, _ -> ExitTransition.None}
                    )