Yur*_*raj 33
只有在下载后才能获得位图尺寸 - 你必须使用这样的同步方法调用:
final Bitmap image = Picasso.with(this).load("http://").get();
int width = image.getWidth();
int height = image.getHeight();
Run Code Online (Sandbox Code Playgroud)
在此之后,您可以使用相同的URL再次调用load(它将从缓存中获取):
Picasso.with(this).load("http://").into(imageView)
Run Code Online (Sandbox Code Playgroud)
编辑:也许更好的方式:
Picasso.with(this).load("http://").into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
imgView.setImageBitmap(bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
Run Code Online (Sandbox Code Playgroud)