1.Glide给控件加载图片:
// Picasso.with(MainActivity.this).load(more.get(position).getUrl())
// .into(holder.IM);
Glide.with(MainActivity.this).load(more.get(position).getUrl())
.into(holder.IM);
为什么 有的图片第一次加载的时候只显示占位图,第二次才显示正常的图片呢?
为什么 我总会得到类似You cannot start a load for a destroyed activity这样的异常呢?
为什么 我不能给加载的图片setTag()呢?
为什么?为什么?这么NB的库竟然会有这么多的问题。没错,这就是我今天要讲的重点。怎么避免上面的问题发生。
Glide.with(this)
.load(R.drawable.thumbnail)
.bitmapTransform(new CropCircleTransformation(this))
.into(mProfile);
XML
<ImageView
android:id="@+id/img_profile"
android:layout_width="76dp"
android:layout_height="76dp"
android:background="@drawable/all_circle_white_bg"
android:padding="1dp"/>
all_circle_white_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="@android:color/white"/>
</shape>
</item>
</selector>
- I use this transformation library. -> https://github.com/wasabeef/glide-transformations
- Circle stroke width is ImageView's padding