How to stop an ValueAnimator without Listener.onAnimationEnd called
Use cancel()
or stop()
, along with a boolean
field somewhere. The boolean
serves as a flag to tell onAnimationEnd()
whether or not it should do its regular work. Default that boolean
to true
; flip it to false
when you want to block normal animation-end processing.
Under certain circumstances, the use of the flag may cause problems.
You should using removeListener before call cancel method:
animator.removeAllListeners(); // Or animator.removeListener(your listener);
animator.cancel();