Android: AnimatedVectorDrawable Loop
You should use AnimatedVectorDrawableCompat instead of AnimatedVectorDrawable to support lower APIs then you can also write that callback and start animation when it ends.Finally your code should be like this:
val animated = AnimatedVectorDrawableCompat.create(this, R.drawable.avd_dice) animated?.registerAnimationCallback(object : Animatable2Compat.AnimationCallback() { override fun onAnimationEnd(drawable: Drawable?) { animationView.post { animated.start() } } }) animationView.setImageDrawable(animated) animated?.start()
You can use Animatable2.AnimationCallback and start the AnimatedVectorDrawable animation again in onAnimationEnd
drawable.registerAnimationCallback(new Animatable2.AnimationCallback() { @Override public void onAnimationEnd(Drawable drawable) { avd.start(); }});drawable.start();
use property in your objectAnimator
android:repeatMode="restart" android:repeatCount="infinite"
your object is like that
<objectAnimator android:propertyName="pathData" android:duration="1000" android:valueFrom="path value" android:valueTo="some value" android:valueType="pathType" android:repeatMode="restart" android:repeatCount="infinite" android:interpolator="@android:anim/overshoot_interpolator"/>