我在AnimatorListenerAdapter
中添加ValueAnimator
,但我需要在ValueAnimator
运行的时候停止它。
我尝试了ValueAnimator.cancel()
或ValueAnimator.stop()
,他们都可以停止动画师,但AnimatorListenerAdapter.onAnimationEnd()
被调用,这是我不想要的。
ValueAnimator.pause()
有效,但它仅高于api 19,所以我无法使用它;
我还能做到这一点吗?
答案 0 :(得分:7)
在某些情况下,使用该标志可能会导致问题。
您应在调用取消方法之前使用removeListener:
animator.removeAllListeners(); // Or animator.removeListener(your listener);
animator.cancel();
答案 1 :(得分:4)
在某处使用cancel()
或stop()
以及boolean
字段。 boolean
用作告诉onAnimationEnd()
是否应该正常工作的标志。默认为boolean
至true
;当你想阻止正常的动画结束处理时,将它翻转到false
。