florent37 / ViewAnimator

A fluent Android animation library
Apache License 2.0
2.71k stars 423 forks source link

Unable to repeat animation with timer #36

Open gensin opened 6 years ago

gensin commented 6 years ago

I'm experimenting an issue trying to repeating an animation with a timer. I have the following method:

ViewAnimator.animate(buttonStart) .rotation(360) .duration(2000) .decelerate() .start();

And a timer which call this methods every 4 seconds. It works always the first time but never again in the sequence although the method call is working. Why is this happening? Why I only can call to the animation once? Am I doing something wrong?

efraespada commented 6 years ago

@gensin you can use repeatCount method for that purpose:

ViewAnimator.animate(buttonStart)
   .rotation(360)
   .duration(4000) // 4 seconds
   .decelerate()
   .repeatCount(android.view.animation.Animation.INFINITE)
   .start();