A fast ImageView (and Drawable) that supports rounded corners (and ovals or circles) based on the original example from Romain Guy. It supports many additional features including ovals, rounded rectangles, ScaleTypes and TileModes.

There are many ways to create rounded corners in android, but this is the fastest and best one that I know of because it:

  • does not create a copy of the original bitmap
  • does not use a clipPath which is not hardware accelerated and not anti-aliased.
  • does not use setXfermode to clip the bitmap and draw twice to the canvas.

If you know of a better method, let me know (or even better open a pull request)!

Also has proper support for:

  • Borders (with Colors and ColorStateLists)
  • Ovals and Circles
  • All ScaleTypes
    • Borders are drawn at view edge, not bitmap edge
    • Except on edges where the bitmap is smaller than the view
    • Borders are not scaled up/down with the image (correct width and radius are maintained)
  • Anti-aliasing
  • Transparent backgrounds
  • Hardware acceleration
  • Support for LayerDrawables (including TransitionDrawables)
  • TileModes for repeating drawables