vxhviet
6/6/2016 - 2:03 PM

How to do multiple animation at the same time with the xml?

How to do multiple animation at the same time with the xml?

Source: StackOverflow, StackOverflow, Cogito, AndroidHive

Question: How to do complex rotate, zoom out, fade animation?

Answer:

Create res/anim/complex_animation.xml with the following content:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:fillAfter="true" >
    <rotate
        android:interpolator="@android:anim/linear_interpolator" //rotate need to be on top see first link
        android:duration="1500"
        android:fromDegrees="0"
        android:toDegrees="358"
        android:pivotX="50%"
        android:pivotY="50%"
        android:repeatCount="infinite"
        android:repeatMode="reverse"/>

    <scale
        android:duration="1500"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="0.1"
        android:toYScale="0.1"
        android:repeatCount="infinite"
        android:repeatMode="reverse"/>

    <alpha
        android:interpolator="@android:anim/accelerate_interpolator"
        android:duration="1500"
        android:fromAlpha="1.0"
        android:toAlpha="0.0"
        android:repeatCount="infinite"
        android:repeatMode="reverse"/>
</set>