get Activity Start Animation - Android android.view.animation

Android examples for android.view.animation:Animation

Description

get Activity Start Animation

Demo Code

import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

public class Main{

    public static final int DURATION = 700;
    public static Animation getActivityStartAnimation() {
        AnimationSet animationSet = new AnimationSet(false);
        AlphaAnimation alphaAnimation = (AlphaAnimation) getFadeInAnimation(DURATION);
        TranslateAnimation translateAnimation = new TranslateAnimation(
                Animation.RELATIVE_TO_PARENT, 1f,
                Animation.RELATIVE_TO_PARENT, 0f,
                Animation.RELATIVE_TO_PARENT, 0f,
                Animation.RELATIVE_TO_PARENT, 0f);
        translateAnimation.setDuration(DURATION);
        animationSet.addAnimation(alphaAnimation);
        animationSet.addAnimation(translateAnimation);
        animationSet.setFillAfter(false);
        return animationSet;
    }/*from   w  w  w .  j  a v  a2s .  co m*/
    private static Animation getFadeInAnimation(int duration) {
        AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
        alphaAnimation.setDuration(duration);
        return alphaAnimation;
    }
    public static Animation getFadeInAnimation() {
        return getFadeInAnimation(DURATION * 2);
    }

}

Related Tutorials