Get the "in" animation from left for the ViewFlipper. - Android Animation

Android examples for Animation:Animation to Show

Description

Get the "in" animation from left for the ViewFlipper.

Demo Code


//package com.java2s;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;

public class Main {
    private static final int FLIPPER_ANIMATION_DURATION = 350;
    private static Animation mInFromLeftAnimation = null;

    /**/*w w  w. ja  v  a  2 s . c  o  m*/
     * Get the "in" animation from left for the ViewFlipper.
     * @return The animation.
     */
    public static Animation getInFromLeftAnimation() {
        if (mInFromLeftAnimation == null) {
            mInFromLeftAnimation = new TranslateAnimation(
                    Animation.RELATIVE_TO_PARENT, -1.0f,
                    Animation.RELATIVE_TO_PARENT, 0.0f,
                    Animation.RELATIVE_TO_PARENT, 0.0f,
                    Animation.RELATIVE_TO_PARENT, 0.0f);

            mInFromLeftAnimation.setDuration(FLIPPER_ANIMATION_DURATION);
            mInFromLeftAnimation
                    .setInterpolator(new AccelerateInterpolator());
        }

        return mInFromLeftAnimation;
    }
}

Related Tutorials