Skip to content

Instantly share code, notes, and snippets.

@kaushikgopal
Last active March 25, 2024 13:55
Show Gist options
  • Star 52 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save kaushikgopal/6c25bc9470bbd11fcf7c to your computer and use it in GitHub Desktop.
Save kaushikgopal/6c25bc9470bbd11fcf7c to your computer and use it in GitHub Desktop.
RoundedImageView - drop dead easy way to do this with RoundedBitmapDrawable
Bitmap batmapBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.batman);
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), batmapBitmap);
// option 1 h/t [Chris Banes](https://chris.banes.me/)
circularBitmapDrawable.setCornerRadius(batmapBitmap.getWidth());
// option 2 h/t @csorgod in the comments
circularBitmapDrawable.setCircular(true);
myImageView.setImageDrawable(circularBitmapDrawable);
System.out.prinln("MyActivity", "That's all folks");
@csorgod
Copy link

csorgod commented Nov 20, 2016

Awesome!

You can use circularBitmapDrawable.setCircular(true) instead of "circularBitmapDrawable.setCornerRadius(batmapBitmap.getWidth());".

@kaushikgopal
Copy link
Author

@csorgod : hot damn! oddly i've never run into it. Thanks! will add that usage too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment