I have a kinda complex vector drawable that I want to animate. I used @RomanNurik\'s web tool to create the animation from a svg
That gives me a valid
The official and working answer is here: https://issuetracker.google.com/issues/64591234
This code works with >= API 16 (probably also 14-15). I'm using support library 26.1.0 and vectorDrawables.useSupportLibrary = true (so I can refer to a vector drawable in xml without crashing)
animatedVector = AnimatedVectorDrawableCompat.create(getContext(), R.drawable.animated_clock);
ringingAlarmImage.setImageDrawable(animatedVector);
final Handler mainHandler = new Handler(Looper.getMainLooper());
animatedVector.registerAnimationCallback(new Animatable2Compat.AnimationCallback() {
@Override
public void onAnimationEnd(final Drawable drawable) {
mainHandler.post(new Runnable() {
@Override
public void run() {
animatedVector.start();
}
});
}
});
animatedVector.start();