Skip to content

Instantly share code, notes, and snippets.

@virendersran01
Forked from muthuraj57/AvatarView.java
Created July 11, 2020 11:30
Show Gist options
  • Save virendersran01/d39895160d8b0ab60f335e478a5f4c4c to your computer and use it in GitHub Desktop.
Save virendersran01/d39895160d8b0ab60f335e478a5f4c4c to your computer and use it in GitHub Desktop.
@Override
protected void onDraw(Canvas canvas) {
if (shape == RECTANGLE) {
canvas.drawRoundRect(rectF, cornerRadius, cornerRadius, borderPaint);
clipPath.addRoundRect(rectF, cornerRadius, cornerRadius, Path.Direction.CW);
} else {
canvas.drawCircle(rectF.centerX(), rectF.centerY(), (rectF.height() / 2) - borderWidth, borderPaint);
clipPath.addCircle(rectF.centerX(), rectF.centerY(), (rectF.height() / 2), Path.Direction.CW);
}
canvas.clipPath(clipPath);
super.onDraw(canvas);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment