Android examples for Animation:Animation Creation
build Reversed Animation into a List of Animator
//package com.java2s; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.view.View; import android.view.ViewGroup; import java.util.ArrayList; import java.util.List; public class Main { public static List<Animator> buildReversed(final ViewGroup view, int pivotX, int pivotY, float fraction, int duration, int delay) { List<Animator> animatorList = new ArrayList<>(); for (int i = 0; i < view.getChildCount(); i++) { View childView = view.getChildAt(i); int deltaX = pivotX - (childView.getLeft() + childView.getWidth() / 2); int deltaY = pivotY - (childView.getTop() + childView.getHeight() / 2); ObjectAnimator xAnim = ObjectAnimator.ofFloat(childView, "translationX", 0, fraction * deltaX); ObjectAnimator yAnim = ObjectAnimator.ofFloat(childView, "translationY", 0, fraction * deltaY); xAnim.setDuration(duration); xAnim.setStartDelay(delay);/*from www. j a v a 2 s . co m*/ yAnim.setDuration(duration); yAnim.setStartDelay(delay); animatorList.add(xAnim); animatorList.add(yAnim); } ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f); alphaAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.INVISIBLE); } }); alphaAnim.setDuration(duration); alphaAnim.setStartDelay(delay); animatorList.add(alphaAnim); return animatorList; } }