我有以下代码(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
运行时触摸屏幕,则它将正确开始向后工作(因为交换了值)。但是,如果在完成后触摸屏幕,则什么也不会发生,也不会重新开始。
问题是我可以以某种方式重用此动画制作器,并使其停止后再次在给定值下工作吗?
您不能重复使用动画。
您需要通过调用initialize()方法来重设()并重新初始化动画对象,然后再次使用同一对象。这类似于实例化新的动画对象。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句