Android examples for android.view.animation:Translate Animation
translate view along the x axis
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.view.View; public class Main{ /**/*from w w w . j a v a 2s .c o m*/ * translate along the x axis * * @param view * @param from * @param to * @param duration * @param listener animator listener adapter, can be null * @return ObjectAnimator */ public static ObjectAnimator translateX(View view, float from, float to, int duration, AnimatorListenerAdapter listener) { ObjectAnimator translationX = ObjectAnimator.ofFloat(view, "translationX", from, to); translationX.setDuration(duration); if (listener != null) { translationX.addListener(listener); } translationX.start(); return translationX; } }