Last active
March 25, 2024 13:55
-
-
Save kaushikgopal/6c25bc9470bbd11fcf7c to your computer and use it in GitHub Desktop.
RoundedImageView - drop dead easy way to do this with RoundedBitmapDrawable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome!
You can use circularBitmapDrawable.setCircular(true) instead of "circularBitmapDrawable.setCornerRadius(batmapBitmap.getWidth());".