I need to add a circle around the canvas every time I click a button (behavior identical to Windows Paint). But to move the circle clicked on the screen I need an ID. Anyone have any idea where I can add this ID? Thank you in advance.
I need to add a circle around the canvas every time I click a button (behavior identical to Windows Paint). But to move the circle clicked on the screen I need an ID. Anyone have any idea where I can add this ID? Thank you in advance.
The easiest way to do this is to create a Custom View
. Not to mention that this will probably prevent boilerplate in your code.
private class CircleCanvas extends View {
public CircleCanvas(Context context) {
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
...
createCircle(...)
}
}
And when you create the circle in your code, use the method View#setId()
.
CircleCanvas circle = new CircleCanvas(ctx);
circle.setId(CIRCLE_ID);