mr.boyfox mr.boyfox - 4 months ago 319
Android Question

How do rounded image with Glide library?

So, anybody know how to display an image with rounded corners with Glide?
I am loading an image with Glide, but I don't know how to pass rounded params to this library.

I need display image like following example:

enter image description here

Answer

You can use RoundedBitmapDrawable for circular Images with Glide. No Custom ImageView is required.

 Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) {
        @Override
        protected void setResource(Bitmap resource) {
            RoundedBitmapDrawable circularBitmapDrawable =
                    RoundedBitmapDrawableFactory.create(context.getResources(), resource);
            circularBitmapDrawable.setCircular(true);
            imageView.setImageDrawable(circularBitmapDrawable);
        }
    });
Comments