How to round an image with Glide library?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Glide makes it easy to load remote or local images into Android views, and it also includes common image transformations. If you want a circular avatar or a rectangle with rounded corners, you usually do not need a custom bitmap transformation at all.
Use Glide's Built-In Circle Crop
For profile photos and similar UI, the simplest option is Glide's built-in circle crop transformation. The code is short and works well when the target ImageView is square or already constrained by layout.
The important call is circleCrop(). Glide scales and crops the image so it fills a circular frame instead of only masking the original bitmap shape.
Round the Corners of a Rectangular Image
If you want cards, thumbnails, or banners with rounded corners, use RoundedCorners. In most cases you should combine it with CenterCrop so the image fills the view first.
RoundedCorners expects pixels, not density-independent units. Converting dp to pixels keeps the appearance consistent across devices.
Add Placeholders and Error Images
Rounded images are usually part of user-facing UI, so a polished loading experience matters. Glide lets you keep the same transformation while also handling loading and failure states.
This pattern prevents blank UI while the request is in progress and gives users a fallback if the request fails.
You can also apply the same transformation to local drawable resources:
That makes testing easy even before a network API is available.
If your UI depends on a very specific shape, define the view dimensions clearly in XML. A circular crop applied to a wide rectangular target still fills the target view, so layout constraints matter just as much as the Glide request.
Common Pitfalls
One common mistake is passing a raw dp value into RoundedCorners. Because the API expects pixels, a value like 16 will appear much smaller on high-density devices than you intended. Convert units before building the request.
Another issue is using RoundedCorners without an appropriate scaling transformation. If the source image and the view have different aspect ratios, the result can look oddly stretched or leave unexpected empty space. CenterCrop is a good default when you want the image to fully cover the view.
Developers also sometimes write custom transformations too early. Glide already provides circleCrop() and RoundedCorners, which are easier to maintain and integrate better with caching. Reach for a custom transformation only when you need a shape or effect that Glide does not already support.
Finally, remember that the view itself can clip your result. If the parent layout, the ImageView scale type, or another style attribute conflicts with Glide's transformation, the final appearance may not match your expectation. When debugging, inspect both the Glide request and the layout XML.
Summary
- Use
circleCrop()for circular avatars and other round image presentations. - Use
transform(CenterCrop(), RoundedCorners(radiusPx))for rounded rectangular images. - Convert
dpto pixels before passing a radius toRoundedCorners. - Add placeholders and error drawables so loading states look intentional.
- Prefer Glide's built-in transformations before writing custom bitmap code.

