Android 如何在没有调用Listener.onAnimationEnd的情况下停止ValueAnimator

Android 如何在没有调用Listener.onAnimationEnd的情况下停止ValueAnimator,android,android-animation,objectanimator,Android,Android Animation,Objectanimator,我将animatorListeneraAdapter添加到ValueAnimator中,但我需要在运行ValueAnimator时停止它 我尝试了ValueAnimator.cancel()或ValueAnimator.stop(),它们都可以停止动画师,但是调用了AnimatorListenerAdapter.onAnimationEnd(),我不想这样做 ValueAnimator.pause()可以工作,但它仅高于api 19,所以我不能使用它 还有其他方法可以这样做吗?使用cancel(

我将
animatorListeneraAdapter
添加到
ValueAnimator
中,但我需要在运行
ValueAnimator
时停止它

我尝试了
ValueAnimator.cancel()
ValueAnimator.stop()
,它们都可以停止动画师,但是调用了
AnimatorListenerAdapter.onAnimationEnd()
,我不想这样做

ValueAnimator.pause()
可以工作,但它仅高于api 19,所以我不能使用它


还有其他方法可以这样做吗?

使用
cancel()
stop()
,以及某个
boolean
字段。
boolean
用作一个标志,告诉
onAnimationEnd()
它是否应该执行常规工作。默认值为
boolean
true
;如果要阻止正常动画结束处理,请将其翻转到
false

在某些情况下,使用该标志可能会导致问题

您应该在调用取消方法之前使用removeListener:

animator.removeAllListeners(); // Or animator.removeListener(your listener);
animator.cancel();

为什么不在某个地方使用
boolean
字段来通知您的
onAnimationEnd()
实现“嘿,不要进行正常的处理”@commonware这就是答案。@Commonware您可以发布答案以便我可以接受。是否有任何文档表明这是
onAnimationEnd()的行为
?@toobsco42:我不确定您在寻找什么文档。我描述的是
onAnimationEnd()
的一个实现,它将使用
布尔值来确定是否应该正常工作。ValueAnimator.cancel(boolean)notfound@maXp: