undo Stick To Animation - Android Animation

Android examples for Animation:Animation Creation

Description

undo Stick To Animation

Demo Code


//package com.java2s;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;

import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;

public class Main {
    private static final int ANIMATE_DURATION = 700;
    private static final Interpolator ANIMATE_INTERPOLATOR = new AccelerateDecelerateInterpolator();

    public static void undoStickTo(final View v, ViewGroup main) {
        v.setLayerType(View.LAYER_TYPE_HARDWARE, null);

        v.animate().y(main.getHeight()).alpha(0)
                .setDuration(ANIMATE_DURATION)
                .setInterpolator(ANIMATE_INTERPOLATOR)
                .setListener(new AnimatorListenerAdapter() {
                    @Override/*from  ww w.  j  ava 2 s. c o m*/
                    public void onAnimationEnd(Animator animation) {
                        v.setLayerType(View.LAYER_TYPE_NONE, null);
                        super.onAnimationEnd(animation);
                    }
                }).start();
    }
}

Related Tutorials