Create fly in From Top Alpha Animation with relative to parent - Android Animation

Android examples for Animation:Alpha Fly Animation

Description

Create fly in From Top Alpha Animation with relative to parent

Demo Code


//package com.java2s;
import android.view.animation.AccelerateInterpolator;
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 Animation inFromTopAlphaAnimation() {
        AnimationSet set = new AnimationSet(true);

        set.addAnimation(inFromTopAnimation());
        set.addAnimation(inAlphaAnimation());

        return set;
    }/*from  w ww  . j  a v a2  s.c o  m*/

    public static Animation inFromTopAnimation() {
        Animation inFromRight = new TranslateAnimation(
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, -1.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f);
        inFromRight.setDuration(350);
        inFromRight.setInterpolator(new AccelerateInterpolator());
        return inFromRight;
    }

    public static Animation inAlphaAnimation() {
        AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f);
        alpha.setDuration(1000);
        alpha.setInterpolator(new AccelerateInterpolator());
        return alpha;
    }
}

Related Tutorials