Android把Glide加载的图片变为圆形头像
原图:
效果图:
添加依赖:
compile 'com.github.bumptech.glide:glide:3.7.0'
代码实现:
Glide.with(getContext()).load("http://www.qqzhi.com/uploadpic/2014-09-12/094013726.jpg").asBitmap().centerCrop().into(new BitmapImageViewTarget(iv_user_head) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), resource);
circularBitmapDrawable.setCircular(true);
iv_user_head.setImageDrawable(circularBitmapDrawable);
}
});
over~