I’ve been playing around with `AnimatedContent` fo...
# compose
m
I’ve been playing around with
AnimatedContent
for screen transitions and I seem to have hit a road block.
ContentTransform
is restricted to fades, slides, and size changes, so I don’t see a way to use this for something more complex that uses child elements. Ex: fade the screen background in, then fade the content in. A more extreme example would be a shared element transition. Is the
AnimatedContent
API meant to be used for things like this, or is there another more general API that could be used?
👋 1
l
You should have a look at Crossfade source, they tween the alpha of both screens, but I recon you could change the animation to be whatever you want https://cs.android.com/androidx/platform/tools/dokka-devsite-plugin/+/master:testDat[…]ompose/animation/Crossfade.kt?q=lang:kotlin%20usage:Crossfade
m
Hmm, yeah.
Crossfade
doesn’t seem like a very complex starting point for building my own thing. I’m still curious to hear if there’s something else that I can use as is, either now or coming soon.
a
You have a
AnimatedVisibilityScope
in
AnimatedContent
and there is a
transition
property. You can use that to create custom animations.
c
Just came here to say I really enjoyed your droidcon talks Matt. I learned a ton from them. Thank you!
❤️ 1
m
so
AnimatedContent
is THE api for screen transition animation? or you are just trying to implement it that way and
TransitionAnimation
will come before stable release?
m
thank you very much
m
Hmm, ok. Found some more docs. You’re suggesting I use
transition
like so? https://developer.android.com/reference/kotlin/androidx/compose/animation/EnterExitState
👌 1
that looks promising. thanks!
👍 1