android AnimatorSet和Object/ValueAnimator的持续时间有什么区别?

0kjbasz6  于 2023-06-20  发布在  Android
关注(0)|答案(1)|浏览(100)

我有一个AnimatorSet和几个ObjectAnimators。我看不出它们持续时间的区别。有人能给我解释一下吗?

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:ordering="together">
    <objectAnimator
        android:propertyName="translationY"
        android:duration="1000"
        android:interpolator="@android:interpolator/bounce"
        android:repeatCount="3"
        android:valueFrom="0.0"
        android:valueTo="-600.0"
        android:repeatMode="reverse"
        android:valueType="floatType"/>
    <objectAnimator
        android:propertyName="alpha"
        android:duration="1000"
        android:interpolator="@android:interpolator/linear"
        android:repeatCount="3"
        android:valueFrom="1.0"
        android:valueTo="0.0"
        android:repeatMode="reverse"
        android:valueType="floatType"
        />
</set>

val rocketAnimatorSet = AnimatorInflater.loadAnimator(this, R.animator.jump_and_blink) as AnimatorSet
    val dogeAnimatorSet = AnimatorInflater.loadAnimator(this, R.animator.jump_and_blink) as AnimatorSet

    rocketAnimatorSet.setTarget(rocket)
    dogeAnimatorSet.setTarget(doge)

    val animatorSet = AnimatorSet()
    animatorSet.playTogether(rocketAnimatorSet, dogeAnimatorSet)
    animatorSet.duration =9000L
    animatorSet.start()
wfveoks0

wfveoks01#

我认为主要的区别是AnimatorSet提供了方法playTogether来合并很多ObjectAnimators或set tag(<set></set>)来包含多个objectAnimators。希望这个有帮助!
AnimatiorSet ref
ObjectAnimator ref

相关问题