Loading images into background of an ImageView using Picasso


Using Picasso in your app for downloading images into ImageView is quite common these days. But can we download an image and set it as background at run time using Picasso?

The answer to this question is ‘ yes ‘, but of course it will require some extra piece of coding.

So, let’s have a look at this extra piece of code.

Simple Picasso request:

Of- course you can add a whole lot of options to this image like resize(), fit(), placeholder() as per your needs.

But the steps for loading an image into background goes like this:

  1. Add a new target, instead of just passing the reference of an imageview.
  2. You will get three default methods namely onBitmapLoaded(), onBitmapFailed(),onPrepareFailed().
    Change the code segment under the function onBitmapLoaded() as per your need and you are done.

Sample CODE:

And, it’s done.

P.S: you can always use any of the other options with this request and you are open to replacing the drawable with URL of your image.

Keep Coding, Keep innovating and Keep sharing. : )



. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.


Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.

Talk to Sales


Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home