create Translate Out Animation - Android Animation

Android examples for Animation:Translate Animation

Description

create Translate Out Animation

Demo Code


//package com.java2s;
import android.content.Context;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;

public class Main {
    public final static int ANIMATION_OUT_TIME = 500;

    public static Animation createOutAnimation(Context context, int toYDelta) {
        AnimationSet set = new AnimationSet(context, null);
        set.setFillAfter(true);//from w  w  w . jav  a2s.  c o  m

        TranslateAnimation animation = new TranslateAnimation(0, 0, 0,
                toYDelta);
        animation.setDuration(ANIMATION_OUT_TIME);
        set.addAnimation(animation);

        AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
        alphaAnimation.setDuration(ANIMATION_OUT_TIME);
        set.addAnimation(alphaAnimation);

        return set;
    }
}

Related Tutorials