Override onTouchEvent
.
Use instance variables float x,y
@Override
public boolean onTouchEvent(MotionEvent event) {
x = event.getX();
y = event.getY();
invalidate(); // to refresh draw
return true;
}
Use x
and y
to draw the image.
public boolean onTouchEvent (MotionEvent event)
Added in API level 1
Implement this method to handle touch screen motion events.
If this method is used to detect click actions, it is recommended that the actions be performed by implementing and calling performClick(). This will ensure consistent system behavior, including:
obeying click sound preferences
dispatching OnClickListener calls
handling ACTION_CLICK when accessibility features are enabled
Parameters
event The motion event.
Returns
True if the event was handled, false otherwise.
You need to know the center and the radius of the circle to detect touch withing the circle.
My be this helps you understand
Creating a spray effect on touch draw in android