Reputation: 87
I'm using Picasso
class/library to load an image from an url
and display the image to a ImageView
. Is it possible for me to set the imageview
loaded by the picasso image loader from an url
as the background image of a linearlayout
programmatically?
Upvotes: 0
Views: 827
Reputation: 19351
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(){
@Override
public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) {
mainLayout.setBackground(new BitmapDrawable(context.getResources(), bitmap));
}
@Override
public void onBitmapFailed(final Drawable errorDrawable) {
Log.d("TAG", "FAILED");
}
@Override
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.
Upvotes: 2