Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Extension of Volley's NetworkImageView that fades in images as they're loaded
import android.content.Context;
import android.util.AttributeSet;
public class FadeInNetworkImageView extends NetworkImageView {
private static final int FADE_IN_TIME_MS = 250;
public FadeInNetworkImageView(Context context) {
public FadeInNetworkImageView(Context context, AttributeSet attrs) {
super(context, attrs);
public FadeInNetworkImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
public void setImageBitmap(Bitmap bm) {
TransitionDrawable td = new TransitionDrawable(new Drawable[]{
new ColorDrawable(android.R.color.transparent),
new BitmapDrawable(getContext().getResources(), bm)
Copy link

Teiby1 commented Jul 4, 2015

ColorDrawable can be replaced by getDrawable() if setDefaultImageResId() was called before.

Copy link

Very useful! Is possible to remove the effect once that an image has been viewed? In a list of images the effect is annoying when scroll down and scroll up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment