Glide踩小坑

最近使用Glide这个框架可没少采坑,这里先记录下踩过的坑(谁让这个框架太牛逼内,我们还带用哈),不懂源码真可怕,等以后看过Glide的源码再回来回味下。

坑1 、 VLayout中使用GridLayoutHelper 加载 item ,图片错位。
部分源码
  Glide
                .with(context)
                .load(entityMainPage.getClassifyGridItems().get(position).getGrid_url())
                .placeholder(R.mipmap.ic_launcher)
                .into(holder.img);

在这里插入图片描述

我自定义的adapter中使用了glide,加载图片时没用使用placeHolder 就错位了。使用了placeholder就正常显示。(网上还有说给glide 加载的ImageView设置tag什么的还没尝试就解决了,看来是时候研究一波源码了)
参考 https://blog.csdn.net/life90/article/details/78884618

坑2 加载单个图片使用了placeholder 图片不正常显示
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/img"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</android.support.v7.widget.LinearLayoutCompat>


   Glide
                .with(context)
                .load(entityMainPage.getSingle_image())
                .placeholder(R.drawable.single)    //设置placeholder 图片不能正常显示
                .into(holder.img);

在这里插入图片描述

placeholder 注释后正常显示:

在这里插入图片描述
参考:https://blog.csdn.net/u010378579/article/details/53317736

小结

以上就是最近踩的坑,不得不吐槽下Glide的坑真多,现在感觉我渣真的迫切需要阅读源码了。
吐槽完毕,溜溜球。。。。。。。。。。。。。。。。。。。。。。。

The end
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值