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 found one easy and simple solution for add border over imageview in which color want to set or add gradient over image.
STEPS:
imgPlaceHolder
, you need one white image or color which you want to set.
After placing this code on xml file , put below line in java file.
Glide.with(this).load(R.drawable.image01).asBitmap().centerCrop().into(new BitmapImageViewTarget(imgPic) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.create(getResources(), resource);
circularBitmapDrawable.setCircular(true);
imageView.setImageDrawable(circularBitmapDrawable);
}
});
Glide.with(this).load(R.drawable.white_bg).asBitmap().centerCrop().into(new BitmapImageViewTarget(imgPlaceHolder) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.create(getResources(), resource);
circularBitmapDrawable.setCircular(true);
imgTemp2.setImageDrawable(circularBitmapDrawable);
}
});
This will make border of imageview simply with out any extra padding and margin.
NOTE : White image is compulsory for border otherwise it will not work.
Happy codding :)