First make utility class or use this method in class needed
public class UIUtils {
public static BitmapImageViewTarget getRoundedImageTarget(@NonNull final Context context, @NonNull final ImageView imageView,
final float radius) {
return new BitmapImageViewTarget(imageView) {
@Override
protected void setResource(final Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.create(context.getResources(), resource);
circularBitmapDrawable.setCornerRadius(radius);
imageView.setImageDrawable(circularBitmapDrawable);
}
};
}
Loading image:
Glide.with(context)
.load(imageUrl)
.asBitmap()
.into(UIUtils.getRoundedImageTarget(context, imageView, radius));
Because you use asBitmap() the animations will be removed though. You can use your own animation in this place using the animate() method.
Example with similar fade in to default Glide animation.
Glide.with(context)
.load(imageUrl)
.asBitmap()
.animate(R.anim.abc_fade_in)
.into(UIUtils.getRoundedImageTarget(context, imageView, radius));
Please note this animation is support library private resource - it is unrecommended to use as it can change or even be removed.
Note you also need to have support library to use RoundedBitmapDrawableFactory