get Activity Start Animation - Android User Interface

Android examples for User Interface:View Animation

Description

get Activity Start Animation

Demo Code


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

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;
    }// w w  w.ja  va  2  s.c  om

    public static Animation getFadeInAnimation() {
        return getFadeInAnimation(DURATION * 2);
    }

    private static Animation getFadeInAnimation(int duration) {
        AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
        alphaAnimation.setDuration(duration);
        return alphaAnimation;
    }
}

Related Tutorials