Starts given animations all together - Android Animation

Android examples for Animation:Animation Creation

Description

Starts given animations all together

Demo Code


//package com.java2s;
import android.view.View;

import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.Interpolator;

public class Main {


    /**// www . j a  v a  2  s. com
     * Starts given animations all together
     * 
     * @param target
     *            : Source view to animate
     * @param duration
     *            : Animation duration
     * @param interpolation
     *            : Interpolation to apply all animations
     * @param listener
     *            : Animation listener to get notified on necessary
     * @param anims
     *            : Animations to run together
     */
    public static void StartTogether(View target, int duration,
            Interpolator interpolation, AnimationListener listener,
            Animation... anims) {
        AnimationSet set = new AnimationSet(true);
        for (int i = 0; i < anims.length; i++)
            set.addAnimation(anims[i]);

        if (duration != -1)
            set.setDuration(duration);
        if (interpolation != null)
            set.setInterpolator(interpolation);
        if (listener != null)
            set.setAnimationListener(listener);

        target.clearAnimation();
        target.startAnimation(set);
    }
}

Related Tutorials