在没有自定义转换的圆形 ImageView 中加载图像
创建自定义 BitmapImageViewTarget 以将图像加载到:
public class CircularBitmapImageViewTarget extends BitmapImageViewTarget
{
private Context context;
private ImageView imageView;
public CircularBitmapImageViewTarget(Context context, ImageView imageView)
{
super(imageView);
this.context = context;
this.imageView = imageView;
}
@Override
protected void setResource(Bitmap resource)
{
RoundedBitmapDrawable bitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource);
bitmapDrawable.setCircular(true);
imageView.setImageDrawable(bitmapDrawable);
}
}
用法:
Glide
.with(context)
.load(yourimageidentifier)
.asBitmap()
.into(new CircularBitmapImageViewTarget(context, imageView));