问题:
Glide 设置了监听不回调
Glide.with(this.getApplicationContext())
.load(uri)
.addListener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
Log.d(TAG, "onResourceReady: ");
return false;
}
})
.into(imageView);
listener不回调,在百度上查了一圈没有找到解决办法;
解决办法:
.override(100, 100)
What is the size of the ImageView declared in XML? Glide needs to know how big an image the target wants. And does so using a layout listener if the size is not ready yet. Having a hidden ImageView doesn’t go through a layout to save processor cycles for obvious reasons, so it may not have a size yet.
You can try .override(w, h) to specify the size yourself or use explicit sizing (100dp).
翻一下:
用XML声明的ImageView的大小是多少?Glide需要知道目标想要多大的图像。如果尚未准备好大小,则使用布局侦听器执行此操作。隐藏的ImageView不会通过布局来节省处理器周期,因此它可能还没有尺寸。
您可以尝试.override(w, h)自己指定大小,也可以使用显式调整大小(100dp)
希望遇见相同问题的小伙伴能少走弯路