导入依赖
implementation 'com.github.bumptech.glide:glide:4.6.1'
用Glide加载圆形图片
Glide.with(context).load(list.get(position).getImgsrc())
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
.into(holder.img);
导入依赖
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);
}
});
glide设置四个角弧度
//设置图片圆角角度
RoundedCorners roundedCorners= new RoundedCorners(10);
//通过RequestOptions扩展功能
RequestOptions options=RequestOptions.bitmapTransform(roundedCorners);
Glide.with(context).load(model.getImg()).apply(options).into(product_img);