I have been using the animated-vector
in xml to animate some of my vectors by using trimPathEnd
etc with something like this for example :
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/vectordrawable" >
<target android:name="main_path">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="1000"
android:interpolator="@android:interpolator/fast_out_linear_in"
android:propertyName="trimPathEnd"
android:valueFrom="0"
android:valueTo="1"/>
</aapt:attr>
</target>
</animated-vector>
However I would like to know if it is possible to trimPathEnd or trimPathStart without having to use an animation, this is because I would like to achieve a layout where the vector gets drawn based on a screen touch offset, so I guess something like vector.setTrimPathEnd(0.2f);
is what I would need to dynamically change the path end in Java based on a specific offset. All the info I could find was to get this done via an animated-vector
which is not the behavior I need here.
Here is what Lottie document says:
What it mentions is
Lottie
canManually set progress
and AVD cannot. I can't find any Android official document for this but I believe it's true because if you look at theAnimatedVectorDrawable
code, no method allows you to get or set the animation progress.So consider using
Lottie
instead, many cool features and a whole bunch of community resources