https://kotlinlang.org logo
#compose
Title
# compose
j

jannis

12/13/2021, 9:22 AM
Is it possible with the Accompanist Navigation Animation library to perform a Crossfade animation? Currently it fades out the old view and fades in the new one, which is not 100% the same, e.g. you might see the background behind both views while the animation is performed.
a

Albert Chang

12/13/2021, 9:54 AM
By definition cross fade means A fades out and B fades in at the same time so there will always be some time where both are transparent. If you don't want the background to be visible, you may want to use fade in.
j

jannis

12/13/2021, 10:07 AM
I'm observing the animation if my TopAppBar has a different color that the background color of the MaterialTheme. Then the background color from the theme is visible while the animation is in progress. I'm using the default transitions from the Accompanist library (fadein + fadeout).
a

Albert Chang

12/13/2021, 10:09 AM
I'm saying that this is normal with cross fade. If you don't want this you should look at transition patterns other than cross fade.
j

jannis

12/13/2021, 10:41 AM
I see. I need to use some kind of Crossfade though 😕 Maybe I have to wait for the shared element transitions on the navigation roadmap 😉
Ah well. As a workaround it seems to work to just paint something behind the StatusBar/TopAppBar with the same color as the TopAppBar. To be more precise: Behind the
AnimatedNavHost
.
5 Views