Create animation to Fade Out - Android android.view.animation

Android examples for android.view.animation:Fade Animation

Description

Create animation to Fade Out

Demo Code

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.widget.TextView;

public class Main{

    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    public static void animFadeOut(final View view) {
        ViewPropertyAnimator viewPropertyAnimator = view.animate();
        viewPropertyAnimator.alpha(0f);//from  w w w . ja  v  a 2 s . c om
        viewPropertyAnimator.setDuration(300l);
        viewPropertyAnimator.start();

        viewPropertyAnimator.setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                view.setVisibility(View.GONE);
            }
        });
    }

}

Related Tutorials