John Ranniel Sinel John Ranniel Sinel - 2 years ago 315
Android Question

How to set the imageview as the background image of my LinearLayout from Picasso image loader programmatically?

I'm using

class/library to load an image from an
and display the image to a
. Is it possible for me to set the
loaded by the picasso image loader from an
as the background image of a

Answer Source

I've already found this issue - might be useful for you:

How do i set background image with picasso in code

According to that, Use callback of Picasso

Picasso.with(getActivity()).load(R.drawable.table_background).into(new Target(){

    public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) {
       mainLayout.setBackground(new BitmapDrawable(context.getResources(), bitmap));

    public void onBitmapFailed(final Drawable errorDrawable) {
        Log.d("TAG", "FAILED");

    public void onPrepareLoad(final Drawable placeHolderDrawable) {
        Log.d("TAG", "Prepare Load");

Read also

Set background resource using Picasso

but there would you find the same solution.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download