如何使用 ViewProperty 动画师按顺序应用多个动画?
How to apply multiple animation in sequence using ViewProperty animator?
我想在一个视图上应用多个 scaleX 动画。
binding.indicator
.animate()
.scaleX(2f)
.start()
binding.indicator
.animate()
.translationX(binding.indicator.width.toFloat())
.setStartDelay(1000)
.start()
binding.indicator
.animate()
.scaleX(1f)
.setStartDelay(2000)
.start()
我认为最新的动画师只是覆盖了视图上的动画师。我怎样才能做到这一点?
我想按顺序做以下动画:scaleX -> translateX -> scaleX
我想要实现的最终产品:https://imgur.com/a/xfY8ujz
使用 AnimatorSet 并按顺序播放动画:
val anim1 = ObjectAnimator.ofFloat(view, "scaleX", 2f)
val anim2 = ObjectAnimator.ofFloat(view, "translationX", view.width.toFloat())
val anim3 = ObjectAnimator.ofFloat(view, "scaleX", 1f)
val animatorSet = AnimatorSet()
animatorSet.playSequentially(anim1, anim2, anim3)
animatorSet.duration = 3000
animatorSet.interpolator = AccelerateInterpolator()
animatorSet.start()
我想在一个视图上应用多个 scaleX 动画。
binding.indicator
.animate()
.scaleX(2f)
.start()
binding.indicator
.animate()
.translationX(binding.indicator.width.toFloat())
.setStartDelay(1000)
.start()
binding.indicator
.animate()
.scaleX(1f)
.setStartDelay(2000)
.start()
我认为最新的动画师只是覆盖了视图上的动画师。我怎样才能做到这一点?
我想按顺序做以下动画:scaleX -> translateX -> scaleX
我想要实现的最终产品:https://imgur.com/a/xfY8ujz
使用 AnimatorSet 并按顺序播放动画:
val anim1 = ObjectAnimator.ofFloat(view, "scaleX", 2f)
val anim2 = ObjectAnimator.ofFloat(view, "translationX", view.width.toFloat())
val anim3 = ObjectAnimator.ofFloat(view, "scaleX", 1f)
val animatorSet = AnimatorSet()
animatorSet.playSequentially(anim1, anim2, anim3)
animatorSet.duration = 3000
animatorSet.interpolator = AccelerateInterpolator()
animatorSet.start()