【发布时间】:2020-05-09 02:55:13
【问题描述】:
我正在尝试为重复动画添加一些延迟,但 startDelay 不起作用。好像只有第一次播放动画时才有效。
val path = Path().apply {
moveTo(imageView.x, imageView.y)
lineTo(x.toFloat(), y.toFloat())
}
ObjectAnimator.ofFloat(imageView, View.X, View.Y, path).apply {
duration = Random.nextLong(500, 1000)
startDelay = 1000
doOnEnd {
startDelay = 3000
}
start()
}
我也尝试使用Timer 和Handler().postDelayed,但它甚至没有重复:
val path = Path().apply {
moveTo(imageView.x, imageView.y)
lineTo(x.toFloat(), y.toFloat())
}
ObjectAnimator.ofFloat(imageView, View.X, View.Y, path).apply {
duration = Random.nextLong(500, 1000)
startDelay = 1000
doOnStart {
Timer().schedule(object : TimerTask() {
override fun run() {
repeatCount = 1
repeatMode = ValueAnimator.REVERSE
}
}, 3000)
}
start()
}
如何实现反向模式下的重复延迟?
【问题讨论】:
标签: java android kotlin android-activity android-animation