Animate a view to fade out. - Android Animation

Android examples for Animation:Fade Animation

Description

Animate a view to fade out.

Demo Code


//package com.java2s;

import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Interpolator;

public class Main {

    public static void startFadeOut(View view, long duration,
            Interpolator interpolator) {
        AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0f);
        if (duration > 0) {
            alphaAnimation.setDuration(duration);
        }/*from   w  w  w  .jav a2 s . c  o  m*/
        if (interpolator != null) {
            alphaAnimation.setInterpolator(interpolator);
        }
        view.startAnimation(alphaAnimation);
    }
}

Related Tutorials