I have an Animation that animates properly and correct the first time I'm running it.
But in my application I have a Button and when I click on that I want to animate exactly as I did the first time, but instead its not animating at all.
Any ideas? Don't think this is code related, its seems that I'm missing something from the API.
Just use getAnimation().start();
for your view. It will restart your animation.
When you are using ViewPropertyAnimator without xlm code, you must remember that:
When you are animating a view with a rotation (or anithing else) viewElement.animate.rotate(180), you will change the viewElement attribute in this case rotation!
So if you call again viewElement.animate.rotate(180). Your element will not rotate, cause the rotation is already occured
Solution 1
myView.animate().rotation(myView.getRotation()+180);
Solution 2 (seems equivalent but is different)
myView.animate().setRotation(0);
myView.animate().rotation(180);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With