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