fade Out Completely - Android Animation

Android examples for Animation:Fade Animation

Description

fade Out Completely

Demo Code


//package com.java2s;

import android.animation.ValueAnimator;

import android.view.View;

import android.view.animation.AccelerateDecelerateInterpolator;

public class Main {
    public final static int ANIMATION_DURATION = 300;

    public static void fadeOutCompletely(final View v) {
        ValueAnimator anim = ValueAnimator.ofFloat(0, 1);
        anim.setInterpolator(new AccelerateDecelerateInterpolator());
        anim.setDuration(ANIMATION_DURATION);
        anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override/*from w w  w .  jav a 2  s .  c om*/
            public void onAnimationUpdate(ValueAnimator animation) {
                float fraction = 1f - animation.getAnimatedFraction();
                v.setAlpha(fraction);
                if (fraction == 1f) {
                    v.setVisibility(View.INVISIBLE);
                }
            }
        });
        anim.start();
    }
}

Related Tutorials