Saturday, 22 September 2018

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:

  • sequentially
  • together (default)

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>



from Sequential animation of nested sets

No comments:

Post a Comment