# android

Saket Poddar

02/18/2020, 1:42 PM
I am trying to control AnimatedVectorDrawable based on my network requests. I searched multiple articles but I can start the animation using Animate class, but cannot find to pin point how to handle animated vector drawables based on custom duration or trigger particular target, for example below loading class

Mark Allison

02/18/2020, 1:53 PM
I’m not sure I understand what your issue is, but I’ve written a whole heap of articles on AVD. Perhaps you can find what you’re after in one of these:

Deneb Asecas

02/18/2020, 2:50 PM
Its a good question. If you find how to do it please share it. If I understand you are saying that your are listening the request progress. This means that the progress goes from 0% to 100%. 101 changes in the time. Then, you want to show animation per % of the progress, dont you? If thi is the idea I just can develop a theory: devide the animation in 101 steps and animate every step by progress of the request. Now, IDK what is the best control of the time in this case 😞

Andreas Jost

02/18/2020, 2:50 PM
That's a cool animation. Not Kotlin related, though. If I understand your problem right, instead of saying this animation should take x seconds to finish, you want to bind it to the progress of your network request, so that it behaves like a determine ProgressBar, right?  What you could do, is divide your animation into e.g. 5 states and build an animated-selector. When the progress reaches 20%, you can transition from the first state to the second and so on. More states would make it more precise. Here is an example that could be helpful:


02/19/2020, 12:56 AM

Saket Poddar

02/19/2020, 6:49 AM
@Leeway yeah one of ways in Lottie.... @Andreas Jost I guess there is no avd support to programmatically handles states. I guess using Lottie would be correct way. Above animation is morphing, which u referred is transition.