make View Visible Animated - Android Animation

Android examples for Animation:Animation to Show

Description

make View Visible Animated

Demo Code


//package com.java2s;
import android.annotation.SuppressLint;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

public class Main {
    @SuppressLint("NewApi")
    public static Animation makeVisibleAnimated(final View view) {
        final Animation a = new AlphaAnimation(0.00f, 1.00f);
        a.setDuration(500);/*from   ww  w.j  a va2  s  .  c  o  m*/
        a.setAnimationListener(getFadeInListener(view));

        view.startAnimation(a);

        return a;
    }

    private static AnimationListener getFadeInListener(final View view) {
        final AnimationListener fadeInListener = new AnimationListener() {

            public void onAnimationEnd(final Animation animation) {

            }

            public void onAnimationRepeat(final Animation animation) {

            }

            public void onAnimationStart(final Animation animation) {
                view.setVisibility(View.VISIBLE);
            }
        };

        return fadeInListener;
    }
}

Related Tutorials