alpha Scale In Out Animation - Android Animation

Android examples for Animation:Scale Animation

Description

alpha Scale In Out Animation

Demo Code


//package com.java2s;
import android.content.Context;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;

public class Main {
    public static void alphaScaleInOut(final View view, Context context) {
        AnimationSet animationSet = new AnimationSet(context, null);
        ScaleAnimation scaleAnimation = new ScaleAnimation(0f, 1f, 0f, 1f,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
        animationSet.addAnimation(scaleAnimation);
        animationSet.addAnimation(alphaAnimation);
        animationSet.setDuration(500);// ww w  . j a v a2 s.co  m
        view.startAnimation(animationSet);

        animationSet
                .setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {

                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        AlphaAnimation fade = new AlphaAnimation(1f, 0f);
                        fade.setDuration(500);
                        view.startAnimation(fade);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {

                    }
                });

    }
}

Related Tutorials