@Override
public boolean onTouchEvent(MotionEvent event)
{
float x = event.getX();
float y = event.getY();
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
if (kwadrat) {
rect = new Rect();
touch_start(x, y);
invalidate();
}
tryb_rys = true;
break;
case MotionEvent.ACTION_MOVE:
if (kwadrat && tryb_rys) {
rect.set((int)mX, (int)mY, (int)event.getX(), (int)event.getY());
mCanvas.drawRect(rect, mPaint);
invalidate();
break;
case MotionEvent.ACTION_UP:
tryb_rys = false;
break;
}
return true;
}
I have something like that but when i draw this rectangle it leave a trace. I only want a few lines of code to fix this.