Create View gone Animator - Android android.animation

Android examples for android.animation:Animator

Description

Create View gone 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";
    private final static int DEFAULT_VISBILITY_DURATION = 350;

    public static ObjectAnimator goneAnimator(View view) {
        ObjectAnimator gone = ObjectAnimator.ofFloat(view, View.ALPHA, 1f,
                0f);/*from   ww w. j  a  v  a  2 s .  c  o  m*/
        gone.setDuration(DEFAULT_VISBILITY_DURATION);
        gone.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                view.setVisibility(View.GONE);
            }
        });
        return gone;
    }
}

Related Tutorials