Glide4.0使用教学

首先是普通的使用

 Glide.with(mContext).load(item.getBooksPicture()) 
                .into((ImageView) helper.getView(R.id.sculpture_img));

带缩略图的使用

你传了0.1f作为参数,那么Glide则会显示原图大小的10%。如果原图的尺寸是1000x1000像素,那么缩略图就是100x100像素。由于缩略图会比ImageView要小许多,所以你要确保一个准确的缩放比例。

 Glide.with(mContext).load(item.getBooksPicture())
                .thumbnail(0.1f)
                .into((ImageView) helper.getView(R.id.sculpture_img));

当网络不佳或者图片url为空再比如图片加载失败的使用

   RequestOptions options = new RequestOptions()
//                .placeholder(R.drawable.ic_launcher_background)//图片加载出来前,显示的图片
//                .fallback( R.drawable.ic_launcher_background) //url为空的时候,显示的图片
//                .error(drawable.ic_launcher_background);//图片加载失败后,显示的图片


        Glide.with(mContext).load(item.getBooksPicture())
//                .apply(options)
                .thumbnail(0.1f)
                .into((ImageView) helper.getView(R.id.sculpture_img));

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值