Create gone Animator for View - Android android.animation

Android examples for android.animation:Animator

Description

Create gone Animator for View

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 goneAnimator(View view) {
        ObjectAnimator gone = ObjectAnimator.ofFloat(view, View.ALPHA, 1f,
                0f);/*from www. j  a va  2 s. co m*/
        gone.setDuration(DEFAULT_VISBILITY_DURATION);
        gone.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                view.setVisibility(View.GONE);
            }
        });
        return gone;
    }
}

Related Tutorials