make View Invisible Animated - Android Animation

Android examples for Animation:Animation to Hide

Description

make View Invisible Animated

Demo Code


//package com.java2s;

import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

public class Main {
    public static Animation makeInvisibleAnimated(final View view) {
        final Animation a = new AlphaAnimation(1.00f, 0.00f);
        a.setDuration(500);/*  w  w  w  .j a  va2  s  . c o  m*/
        a.setAnimationListener(getFadeOutListener(view));

        view.startAnimation(a);

        return a;
    }

    private static AnimationListener getFadeOutListener(final View view) {
        final AnimationListener fadeOutListener = new AnimationListener() {

            public void onAnimationEnd(final Animation animation) {
                view.setVisibility(View.INVISIBLE);
            }

            public void onAnimationRepeat(final Animation animation) {

            }

            public void onAnimationStart(final Animation animation) {

            }
        };

        return fadeOutListener;
    }
}

Related Tutorials