Animate a view to fade in. - Android Animation

Android examples for Animation:Fade Animation

Description

Animate a view to fade in.

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 startFadeIn(View view, long duration,
            Interpolator interpolator) {
        AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
        if (duration > 0) {
            alphaAnimation.setDuration(duration);
        }/*from  www .ja  v  a 2 s.  c  o  m*/
        if (interpolator != null) {
            alphaAnimation.setInterpolator(interpolator);
        }
        view.startAnimation(alphaAnimation);
    }
}

Related Tutorials