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.
You can simply call the RoundedCornersTransformation constructor, which has cornerType enum input. Like this:
Glide.with(context)
.load(bizList.get(position).getCover())
.bitmapTransform(new RoundedCornersTransformation(context,20,0, RoundedCornersTransformation.CornerType.TOP))
.into(holder.bizCellCoverImg);
but first you have to add Glide Transformations to your project.
its very simple i have seen Glide library its very good library and essay base on volley Google's library
usethis library for rounded image view
https://github.com/hdodenhof/CircleImageView
now
//For a simple view:
@Override
public void onCreate(Bundle savedInstanceState) {
...
CircleImageView civProfilePic = (CircleImageView)findViewById(R.id.ivProfile);
Glide.load("http://goo.gl/h8qOq7").into(civProfilePic);
}
//For a list:
@Override
public View getView(int position, View recycled, ViewGroup container) {
final ImageView myImageView;
if (recycled == null) {
myImageView = (CircleImageView) inflater.inflate(R.layout.my_image_view,
container, false);
} else {
myImageView = (CircleImageView) recycled;
}
String url = myUrls.get(position);
Glide.load(url)
.centerCrop()
.placeholder(R.drawable.loading_spinner)
.animate(R.anim.fade_in)
.into(myImageView);
return myImageView;
}
and in XML
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/ivProfile
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_centerInParent="true"
android:src="@drawable/hugh"
app:border_width="2dp"
app:border_color="@color/dark" />
Roman Samoylenko's answer was correct except the function has changed. The correct answer is
Glide.with(context)
.load(yourImage)
.apply(RequestOptions.circleCropTransform())
.into(imageView);
Now in Glide V4 you can directly use CircleCrop()
Glide.with(fragment)
.load(url)
.circleCrop()
.into(imageView);
Built in types
Glide.with(context!!)
.load(randomImage)
.apply(RequestOptions.bitmapTransform(CircleCrop()).error(R.drawable.nyancat_animated))
.transition(DrawableTransitionOptions()
.crossFade())
.into(picture)
The easiest way (requires Glide 4.x.x)
Glide.with(context).load(uri).apply(RequestOptions().circleCrop()).into(imageView)