我有以下代码(Scala中的Android项目):
我有以下代码(Scala中的Android项目):
val animator = new ValueAnimator
animator.setFloatValues(0f, 100f)
animator.setDuration(20000L)
animator.addUpdateListener(this) // prints current value to console
animator.start
override def onTouch(v: View, event: MotionEvent) = {
animator.setFloatValues(100f, 0f)
animator.setCurrentPlayTime(0)
if (!animator.isRunning) animator.start
true
}
如果在animator
运行时触摸屏幕,则会正确地开始向后运行(因为我已经交换了值)。但是,如果在动画完成后触摸屏幕,则不会发生任何事情,它不会重新启动。
问题是,在停止后是否可以以某种方式重用此动画器,并在给定值之后再次正常工作?