Create View becoming visible Animator - Android android.animation

Android examples for android.animation:Animator

Description

Create View becoming visible Animator

Demo Code


//package com.java2s;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.view.View;

public class Main {
    public final static String ALPHA = "alpha";
    public final static int DEFAULT_VISBILITY_DURATION = 350;

    public static ObjectAnimator visibleAnimator(View view) {
        ObjectAnimator visibility = ObjectAnimator.ofFloat(view,
                View.ALPHA, 0f, 1f);
        visibility.setDuration(DEFAULT_VISBILITY_DURATION);
        visibility.addListener(new AnimatorListenerAdapter() {
            @Override/*from w ww . ja va 2 s . c o  m*/
            public void onAnimationStart(Animator animation) {
                view.setVisibility(View.VISIBLE);
            }
        });
        return visibility;
    }
}

Related Tutorials