Android examples for User Interface:ImageView
Fades an imageview.
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 { /**/*from www.j a va 2s. c om*/ * Fades an imageview. * * @param activity * your activity. * @param imageView * your imageview. * @param image * the image you want to fade. */ public static void fadeImage(final Activity activity, final ImageView imageView, final Bitmap image) { Animation exitAnim = AnimationUtils.loadAnimation(activity, android.R.anim.fade_out); 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.fade_in); enterAnim.setDuration(150); imageView.startAnimation(enterAnim); } }); imageView.startAnimation(exitAnim); } }