【发布时间】:2015-04-07 20:51:48
【问题描述】:
我有以下代码(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 运行时触摸屏幕,那么它会正确开始向后工作(因为我已经交换了值)。但是,如果我在完成后触摸屏幕,则什么也不会发生,它不会重新开始。
问题是我可以以某种方式重用这个动画制作器,并在它停止后让它再次为给定的值工作吗?
【问题讨论】:
-
不,你不能。我刚刚检查过了。我也想在我的应用程序中重用它。所以使用克隆来获取一个新实例,然后为每个实例设置目标视图。
标签: android animation reusability