Is it possible to turn off default fade transition...
# compose
k
Is it possible to turn off default fade transition animation?
i
Assuming you're talking about Navigation, you'll want to use Accompanist Navigation Animation, which has APIs for controlling the animations: https://google.github.io/accompanist/navigation-animation/
Which would include the ability to use
EnterTransition.None
k
Thank you.
Would be cool if we wouldn't need to do that, but instead disable it inside NavGraph. What is causing the issue is that if I'm having nested Scaffolds with TopBar's, changing screen makes TopBar flicker (as fade animation kicks in).
f
You can disable it per destination when using Accompanist navigation, and later probably also with the default navigation. Or what do you mean with disable it inside NavGraph?
k
Without Accompanist, fade animation is still present. I'd like to disable that fade animation without Accompanist help.
Animations still seem to be present when used .None on every composable and navigation. (Default Slide in + fade animation)
Copy code
composable(
    route = RandomNavigation.route,
    enterTransition = { _, _ -> EnterTransition.None },
    exitTransition = { _, _ -> ExitTransition.None },
    popEnterTransition = { _, _ -> EnterTransition.None },
    popExitTransition = { _, _ -> ExitTransition.None }
) {
    RandomScreen()
}
f
I think the transition configuration will later come to the normal navigation library.
For turning animations off, specifying
enterTransition
and
exitTransition
on
NavHost
should be enough, since those values are the default for all others too.
And regarding your issue with disabling animations: I can't reproduce it with the following config:
Copy code
AnimatedNavHost(
    navController = navController,
    startDestination = "start",
    enterTransition = { _, _ -> EnterTransition.None },
    exitTransition = { _, _ -> ExitTransition.None },
) {
   // ...
}
k
I do have that, and it still animates.
f
Can you show the full code? Which Accompanist version are you using?
k
0.18.0. Just cleaned uncommitted changes, gonna try something different. Code was straightforward, not much to it. I'm gonna try on blank project.
f
Sounds good.
k
Thanks Felix.
468 Views