Java tutorial
//package com.java2s; //License from project: Open Source License import android.view.View; import android.view.animation.Animation; import android.view.animation.DecelerateInterpolator; import android.view.animation.TranslateAnimation; public class Main { public static void linearAnimation(final View view, final int deltaX, final int deltaY, long duration, final Runnable callback) { linearAnimation(view, 0, 0, deltaX, deltaY, duration, callback); } public static void linearAnimation(final View view, final int startX, final int startY, final int endX, final int endY, long duration, final Runnable callback) { Animation anim = new TranslateAnimation(startX, endX, startY, endY); anim.setDuration(duration); anim.setInterpolator(new DecelerateInterpolator()); view.startAnimation(anim); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { view.clearAnimation(); view.setX(view.getX() + endX); view.setY(view.getY() + endY); if (callback != null) callback.run(); } @Override public void onAnimationRepeat(Animation animation) { } }); } }