iv_fresco=(SimpleDraweeView)findViewById(R.id.iv_fresco);
Glide.with(this).load(url).into(iv_round);
Glide.with(this).load(url).into(iv_cardview);
Uri uri = Uri.parse(url);
iv_fresco.setImageURI(uri);
package roundimageview.forezp.com.roundimageview;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
/**
* Created by Administrator on 2016/8/19 0019.
*/publicclassGlideRoundTransformextendsBitmapTransformation {privatestaticfloat radius = 0f;
publicGlideRoundTransform(Context context) {
this(context, 4);
}
publicGlideRoundTransform(Context context, int dp) {
super(context);
this.radius = Resources.getSystem().getDisplayMetrics().density * dp;
}
@Overrideprotected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
return roundCrop(pool, toTransform);
}
privatestatic Bitmap roundCrop(BitmapPool pool, Bitmap source) {
if (source == null) returnnull;
Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
}
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
canvas.drawRoundRect(rectF, radius, radius, paint);
return result;
}
@Overridepublic String getId() {
return getClass().getName() + Math.round(radius);
}
}