Tom11
Tom11

Reputation: 2527

Return animation / new animation

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.

Upvotes: 3

Views: 61

Answers (0)

Related Questions