Created
August 21, 2014 15:31
-
-
Save ognian-/45fc3fbfd4b04f2515f7 to your computer and use it in GitHub Desktop.
Android circle avatar image
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
/* | |
* Create a circle avatar from a Bitmap. Use in ImageView | |
* with setImageDrawable() | |
*/ | |
public static Drawable makeCircleAvatar(Bitmap bmp) { | |
ShapeDrawable dr = new ShapeDrawable(new OvalShape()); | |
dr.getPaint().setShader(new BitmapShader(bmp, TileMode.CLAMP, TileMode.CLAMP)); | |
dr.setIntrinsicWidth(bmp.getWidth()); | |
dr.setIntrinsicHeight(bmp.getHeight()); | |
return dr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use without hardware acceleration on the ImageView