Get the "out" animation to left for the ViewFlipper. - Android Animation

Android examples for Animation:Animation to Hide

Description

Get the "out" animation to 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 mOutToLeftAnimation = null;

    /**/*from  w w  w  .  ja va2  s  .  c  om*/
     * Get the "out" animation to left for the ViewFlipper.
     * @return The animation.
     */
    public static Animation getOutToLeftAnimation() {
        if (mOutToLeftAnimation == null) {
            mOutToLeftAnimation = new TranslateAnimation(
                    Animation.RELATIVE_TO_PARENT, 0.0f,
                    Animation.RELATIVE_TO_PARENT, -1.0f,
                    Animation.RELATIVE_TO_PARENT, 0.0f,
                    Animation.RELATIVE_TO_PARENT, 0.0f);

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

        return mOutToLeftAnimation;
    }
}

Related Tutorials