Return animation / new animation

73 Views Asked by At

I have animated-vector inside included in ImageView usind android:src. I am using this code in onClick to launch an animation:

Drawable drawable = element.getDrawable();
if (drawable instanceof Animatable) {
    ((Animatable) drawable).start();
}

Simple enough.

However, I want this animation to 'return' to the previous state in onclick. Scenario: Play/Stop. When user clicks play, play is animated to stop. When user clicks again, stop is animated to play. I have both animated-vector drawables, however I can't find a way how to do this. I believe it should be possible but I did not find a simple way. I have found only answers with creating wrappers, running threads to detect animation end etc.

0

There are 0 best solutions below