Subsampling Scale Image View + Glide显示网络图片

本文介绍如何结合Subsampling Scale Image View和Glide在Android项目中加载网络图片。通过Glide将图片下载并缓存到本地,然后在Subsampling Scale Image View中展示,避免了因手动处理图片加载导致的性能问题和复杂性。
摘要由CSDN通过智能技术生成

Subsampling Scale Image View自身只支持本地图片的加载,但项目中还需要显示网络图片,不想分情况选用不同的控件,所以通过Glide将图片下载到本地缓存再显示

 //使用Glide下载图片,保存到本地
            Glide.with(context)
                    .download(uri)
                    .into(new SimpleTarget<File>() {
                        @Override
                        public void onLoadFailed(@Nullable Drawable errorDrawable) {
                            super.onLoadFailed(errorDrawable);
                            Log.d("load failed", "nothing");
                        }

                        @Override
                        public void onResourceReady(File resource, Transition<? super File> transition) {
                            mPlaceHolder.setVisibility(GONE);
                            imageView.setImage(ImageSource.uri(resource.getAbsolutePath()));
                            imageView.setMaxScale(10f);
                        }
                   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值