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

Android examples for Animation:Alpha Fly Animation

Description

Create fly in From Left 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 inFromLeftAlphaAnimation() {
        AnimationSet set = new AnimationSet(true);

        set.addAnimation(inFromLeftAnimation());
        set.addAnimation(inAlphaAnimation());

        return set;
    }//from  w w  w. ja  v a 2  s. c o m

    public static Animation inFromLeftAnimation() {
        Animation inFromLeft = 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);
        inFromLeft.setDuration(350);
        inFromLeft.setInterpolator(new AccelerateInterpolator());
        return inFromLeft;
    }

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

Related Tutorials