Create fly in From Right Alpha Animation - Android Animation

Android examples for Animation:Alpha Fly Animation

Description

Create fly in From Right Alpha Animation

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 inFromRightAlphaAnimation() {
        AnimationSet set = new AnimationSet(true);

        set.addAnimation(inFromRightAnimation());
        set.addAnimation(inAlphaAnimation());

        return set;
    }/*  ww  w.  j ava2s . c o  m*/

    public static Animation inFromRightAnimation() {
        Animation inFromRight = new TranslateAnimation(
                Animation.RELATIVE_TO_PARENT, +1.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.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