Search code examples
androidpicasso

Load from URL to ImageView with Picasso without white flash on ImageView


I'm using the Picasso library from Square to load a URL string into an ImageView. I'm calling this several times on an array or URLs with a Timer to change the ImageView image.

The first time though, when Picasso is loading the URL content, every time the ImageView updates, it flashes white.

After Picasso caches the content, the ImageView changes without the flash.

How do I stop the ImageView from flashing white?

Picasso.with(getApplicationContext()).load(currentUrl).into(img, new Callback() {
                    @Override
                    public void onSuccess() {
                        mProgress.dismiss();
                    }

                    @Override
                    public void onError() {
                        mProgress.dismiss();
                    }
                });

Solution

  • Had the same issue, solved it by adding the noPlaceHolder instruction like this :

    Picasso.with(getApplicationContext())
        .load(currentUrl)
        .noPlaceholder()
        .into(img, new Callback() {
                        @Override
                        public void onSuccess() {
                            mProgress.dismiss();
                        }
    
                        @Override
                        public void onError() {
                            mProgress.dismiss();
                        }
                    });
    

    By default, Picasso will either clear the target ImageView in order to ensure behavior in situations where views are recycled. This method will prevent that behavior and retain any already set image.

    Picasso Documentaton