Android examples for android.animation:Animator
get Expand Top Animators
//package com.java2s; import android.animation.Animator; import android.animation.ObjectAnimator; import android.view.View; import java.util.ArrayList; public class Main { public static ArrayList<Animator> getExpandTopAnimators(int[] center, int expandedWidth, int expandedHeight, ArrayList<View> items) { final ArrayList<Animator> animators = new ArrayList<>(); if (items != null) { final float y = center[1] - expandedHeight / 2; for (int i = 0; i < items.size(); i++) { final float x = getDestinationX(center[0], expandedWidth, items.get(i).getWidth(), items.size(), i); final ObjectAnimator translateX = ObjectAnimator.ofFloat( items.get(i), "X", items.get(i).getX(), x); final ObjectAnimator translateY = ObjectAnimator.ofFloat( items.get(i), "Y", items.get(i).getY(), y - items.get(i).getHeight() / 2); animators.add(translateX); animators.add(translateY); }//from ww w .ja v a 2 s . com } return animators; } public static float getDestinationX(float centerX, int expandedWidth, int itemWidth, int itemSize, int item) { float x = (centerX - expandedWidth / 2) + (expandedWidth / itemSize * item + (expandedWidth / itemSize * (item + 1) - expandedWidth / itemSize * item) / 2) - itemWidth / 2; return x; } }