我使用Jsoup来阅读网站。但在html中,并不是所有的图像都有尺寸信息。因此,如果它不在那里,我想使用图像源URL以某种其他方式找出图像大小。
发布于 2020-02-16 07:02:27
我建议使用glide
dependencies {
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
}
,然后使用glide加载您的图像url。
Glide.with(this)
.asBitmap()
.load(path)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
int width = bitmap.getWidth();
int height = bitmap.getHeight()
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
发布于 2020-11-13 00:15:05
/*this library*/
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
/* this code */
Glide.with(this)
.asFile() // get size image url
.load("link image url")
.into(new SimpleTarget<File>() {
@Override
public void onResourceReady(@NonNull File resource, @Nullable
Transition<? super File> transition) {
fab_full.setLabelText(""+resource.length()); // /1024 kb
}
});
https://stackoverflow.com/questions/60242161
复制相似问题