Skip to content

Instantly share code, notes, and snippets.

@ognian-
Created August 21, 2014 15:31
Show Gist options
  • Save ognian-/45fc3fbfd4b04f2515f7 to your computer and use it in GitHub Desktop.
Save ognian-/45fc3fbfd4b04f2515f7 to your computer and use it in GitHub Desktop.
Android circle avatar image
/*
* 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;
}
@ognian-
Copy link
Author

ognian- commented Sep 6, 2014

Use without hardware acceleration on the ImageView

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