先上效果图:
因注释很细,就不一一解释说明了!
1.Glide加载圆形图片:
自定义GlideCircleTransUtils继承BitmapTransformation,重写transform()方法;
public class GlideCircleTransUtils extends BitmapTransformation {
public GlideCircleTransUtils(Context context) {
super(context);
}
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
return circleCrop(pool, toTransform);
}
private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
if (source == null) return null;
//获取资源的长宽,获取最小值 子位图的像素个数
int size = Math.min(source.ge