I need to make an animation for `Image` using an a...
# compose
a
I need to make an animation for
Image
using an array of
DrawableResIds
. Let say to switch an image every second. Does anyone know how to achieve this using Compose animation API or transition? Or might there is some other way to do it?
z
“Switch an image every second” is a distinct thing from animation. You could launch a coroutine that does this in a loop with a delay, or use a Flow, etc. For animating, how do you want to animate? Might be able to use the
Crossfade
composable.
a
ok, I was thinking about coroutines as well. Will give it a try
Do you know a proper way to run coroutines inside composable? Or should I use something like Flow.asState from VM?
m
@aipok you can use
launchInComposition
and
ticker
or
delay
(give a look here)