Created
June 2, 2015 21:52
-
-
Save mattlogan/0a667fd17f5eb74e48c2 to your computer and use it in GitHub Desktop.
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
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