Glide listener监听不回调问题

问题:

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)

希望遇见相同问题的小伙伴能少走弯路

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值