一、Glide加载圆形头像
ImageView mImage = findViewById(R.id.image);
Requestoptions options = new RequestOptions() .placeholder(R.mipmap.head_icon) .circleCropTransform(); Glide.with(this) .load("图像Uri") .apply(options) .into(mImage);
二、Glide给图像设置圆角
例子:设置图片圆角为10dp
效果
RequestOptions options = new RequestOptions() .placeholder(R.drawable.capture_default) .bitmapTransform(new RoundedCorners(dip2px(mContext, 10))); Glide.with(this) .load("图像Uri") .apply(options) .into(mImage);
public static int dip2px(Context context, float dPValue) { final float scale = context.getResources().getDISPlayMetrics().density; return (int) (dpValue * scale + 0.5f); } public static int px2dip(Context context, float pxValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (pxValue / scale + 0.5f); }