我想用Picasso将图片加载显示到LinerLayout里,用 into(target), 发现第一次并没有调用onBitmapLoaded,第二次才会调用 onBitmapLoaded, 但是每次都会调用onPrepareLoad。
我遇到的bug 上述代码,第一次执行的时候,不会回调onBitmapLoaded, 第二次执行才会调用。
。emmm,然后在stackoverflow上找到了解决办法:
mLayout是一个 LinerLayout。创建一个ImageView作为target,然后通过image获取drawable,然后将drawable设置为mLayout的背景。
ImageView profile = new ImageView(context);
Picasso.with(context).load(URL).into(profile, new Callback() {
@Override
public void onSuccess() {
//You will get your drawable by profile.
Drawable drawable = profile.getDrawable();
}
@Override
public void onError() {
}
});
参考:点击打开链接