【发布时间】:2019-01-03 22:01:10
【问题描述】:
我正在设计要在交错布局中显示的图像。所以,我使用 Target 的 onBitmapLoaded() 方法来保持纵横比。
picasso.load(mCursor.getString(ArticleLoader.Query.THUMB_URL))
.placeholder(R.drawable.photo_background_protection)
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
float width = bitmap.getWidth();
float height = bitmap.getHeight();
float aspectRatio = width / height;
holder.thumbnailView.setAspectRatio(aspectRatio);
holder.thumbnailView.setImageBitmap(bitmap);
holder.imageProgressBar.setVisibility(View.INVISIBLE);
}
});
我想调用onSuccess方法来检查图片是否加载成功,这样可以让progessBar不可见。
【问题讨论】: