Android examples for Animation:Slide Animation
Slides an image off to the right.
import android.app.Activity; import android.graphics.Bitmap; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageView; public class Main { /**/* w ww . ja v a 2 s. c o m*/ * Slides an image off to the right. * * @param activity * your activity. * @param imageView * your imageview. * @param image * the image you want to slide. */ public static void slideImage(final Activity activity, final ImageView imageView, final Bitmap image) { Animation exitAnim = AnimationUtils.loadAnimation(activity, android.R.anim.slide_out_right); exitAnim.setDuration(150); exitAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { imageView.setImageBitmap(image); Animation enterAnim = AnimationUtils.loadAnimation(activity, android.R.anim.slide_in_left); enterAnim.setDuration(150); imageView.startAnimation(enterAnim); } }); imageView.startAnimation(exitAnim); } }