androidandroid-animation

Sequential animation of nested sets


I am currently working on an Android splash screen animation. Google's documentation for animation resources states that <set> has an attribute android:ordering, which "specifies the play ordering of animations in this set". There are two (self-explanatory) options:

The animation.xml below shows a small implementation, but the way it's being executed differs from what I expected. The nested sets are all executed at the same time, although I defined android:ordering="sequentially" for their parent. I expected only the contents of each nested set to be shown simulatneous. Does the ordering attribute of the parent set not affect nested sets?

I am aware of the solution proposed in this answer, but I don't see the reason why my definition of a sequential execution of animations should not work just as well.

animation.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:ordering="sequentially">
    <set>
        <alpha
            android:duration="400"
            android:fromAlpha="0"
            android:interpolator="@anim/interpolator"
            android:toAlpha="0.4" />
        <scale
            android:duration="400"
            android:fromXScale="0"
            android:fromYScale="0"
            android:interpolator="@anim/interpolator"
            android:pivotX="30%"
            android:pivotY="50%"
            android:toXScale="0.4"
            android:toYScale="0.4" />
    </set>
    <set>
        <alpha
            android:duration="200"
            android:fromAlpha="0.4"
            android:toAlpha="0.3" />
        <scale
            android:duration="200"
            android:fromXScale="0.4"
            android:fromYScale="0.4"
            android:pivotX="30%"
            android:pivotY="50%"
            android:toXScale="0.3"
            android:toYScale="0.3" />
    </set>
</set>

Solution

  • There is no ordering attribute on a view animation set.

    I think you are confusing property animation (defined as res/animator/... resources) and view animation (in res/anim/...).

    Both can have a <set> element, but the syntax is different. For a property animation, it's :

    <set
      android:ordering=["together" | "sequentially"]>
    ...
    

    and it creates an AnimatorSet

    while for a view animation, it's :

    <set
        android:interpolator="@[package:]anim/interpolator_resource"
        android:shareInterpolator=["true" | "false"] >
    ...
    

    which creates an AnimationSet