Skip to content

Instantly share code, notes, and snippets.

@muthuraj57
Created December 7, 2016 19:10
Show Gist options
  • Save muthuraj57/fae67986e88446000046ed3d83309be2 to your computer and use it in GitHub Desktop.
Save muthuraj57/fae67986e88446000046ed3d83309be2 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