I am trying to control AnimatedVectorDrawable base...
# android
s
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
m
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: https://blog.stylingandroid.com/category/animatedicons/
d
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 😞
a
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: https://medium.com/@saulmm2/from-design-to-android-part-2-2a6c141547d9
l
s
@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.