Android examples for android.view.animation:Translate Animation
start Translate Self Up Animation
import android.view.View; import android.view.animation.Animation; import android.view.animation.TranslateAnimation; public class Main { public static void startTranslateSelfUpAnimation(View view, long duration, boolean fillAfter, boolean toOriginalPosition) { int toY = toOriginalPosition ? 0 : -1; TranslateAnimation translate = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, toY); translate.setDuration(duration);// www. ja v a 2 s . c o m translate.setFillAfter(fillAfter); startAnimation(view, translate); } public static void startAnimation(View view, Animation anim) { view.clearAnimation(); view.startAnimation(anim); // view.invalidate(); } }