在沒有自定義轉換的圓形 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));