Android examples for android.view.animation:slide Animation
create Slide Animation
import android.view.animation.Animation; import android.view.animation.TranslateAnimation; public class Main{ public static Animation createSlideAnimation(boolean relToParent, boolean horizontal, boolean fromLeftOrTop, boolean exiting, int duration) { int rel = (relToParent ? Animation.RELATIVE_TO_PARENT : Animation.RELATIVE_TO_SELF); float movingFrom = (exiting ? 0f : (fromLeftOrTop ? -1f : 1f)); float movingTo = (exiting ? (fromLeftOrTop ? 1f : -1f) : 0f); TranslateAnimation anim;// w w w . j a v a 2 s . c o m if (horizontal) { anim = new TranslateAnimation(rel, movingFrom, rel, movingTo, rel, 0, rel, 0); } else { anim = new TranslateAnimation(rel, 0, rel, 0, rel, movingFrom, rel, movingTo); } anim.setDuration(duration); return anim; } }