Android examples for android.widget:ImageView
load Bitmap Into ImageView
import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; import android.widget.ImageView; public class Main { public static void loadBitmapIntoView(Context context, ImageView view, Bitmap bm, boolean fadeIn) { final Drawable previousDrawable = view.getDrawable(); if (fadeIn && previousDrawable != null) { final Drawable[] layers = new Drawable[2]; // Prevent cascade of TransitionDrawables. if (previousDrawable instanceof TransitionDrawable) { final TransitionDrawable previousTransitionDrawable = (TransitionDrawable) previousDrawable; layers[0] = previousTransitionDrawable.getDrawable(previousTransitionDrawable.getNumberOfLayers() - 1); } else {//from ww w .j av a2s . c om layers[0] = previousDrawable; } layers[1] = new BitmapDrawable(context.getResources(), bm); TransitionDrawable drawable = new TransitionDrawable(layers); view.setImageDrawable(drawable); drawable.setCrossFadeEnabled(true); drawable.startTransition(200); } else { view.setImageBitmap(bm); } } }