Android examples for User Interface:View Animation
Animates the view to the given x/y coordinates using the given duration and calling the given Runnable once the animation completes.
import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; public class Main{ public static void animateXY(final View pView, final int pX, final int pY, final int pDuration, final Runnable pEndAction) { if (AndroidUtils.isUIThread()) { pView.animate().setDuration(pDuration).x(pX).y(pY) .withEndAction(pEndAction); } else {//from w ww . ja v a 2 s.c o m pView.post(new Runnable() { public void run() { animateXY(pView, pX, pY, pDuration, pEndAction); } }); } } }