What's the difference between AnimatorSet's and Object/ValueAnimator's duration?

171 Views Asked by At

I have a AnimatorSet with couple of ObjectAnimators. I can not see the difference between their duration time. Can anyone explain this to me?

<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()
1

There are 1 best solutions below

0
On

I think the main difference is AnimatorSet provides method playTogether to combine a lot of ObjectAnimators or set tag (<set></set>) to contain multiple objectAnimators. Hope this help!

AnimatiorSet ref

ObjectAnimator ref