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?
Asked
Active
Viewed 826 times
0

AndiGeeky
- 11,266
- 6
- 50
- 66

John Ranniel Sinel
- 87
- 11
1 Answers
2
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.

Community
- 1
- 1

piotrek1543
- 19,130
- 7
- 81
- 94
-
Sadly" new BitmapDrawable" is deprecated – Feb 09 '20 at 17:33