src*_*091 5 animation android reusability
我有以下代码(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
}
Run Code Online (Sandbox Code Playgroud)
如果我在animator运行时触摸屏幕,则它将正确开始向后工作(因为交换了值)。但是,如果在完成后触摸屏幕,则什么也不会发生,也不会重新开始。
问题是我可以以某种方式重用此动画器并使其停止后再次工作以给定值吗?
| 归档时间: |
|
| 查看次数: |
1781 次 |
| 最近记录: |