Skip to content

Instantly share code, notes, and snippets.

@mattlogan
Created June 2, 2015 21:52
Show Gist options
  • Save mattlogan/0a667fd17f5eb74e48c2 to your computer and use it in GitHub Desktop.
Save mattlogan/0a667fd17f5eb74e48c2 to your computer and use it in GitHub Desktop.
public class PinCircle extends View {
private Paint paint;
private float strokeWidth;
public PinCircle(Context context) {
this(context, null);
}
public PinCircle(Context context, AttributeSet attrs) {
super(context, attrs);
strokeWidth = context.getResources().getDimension(R.dimen.pin_circle_stroke_width);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(context.getResources().getColor(R.color.light_gray));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(strokeWidth);
}
public void setFilled(boolean filled) {
paint.setStyle(filled ? Paint.Style.FILL : Paint.Style.STROKE);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawCircle(getWidth() / 2f, getHeight() / 2f, getWidth() / 2f - strokeWidth, paint);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment