Question


Here drawing is not performed while the canvas is resized. It just checks wheather there is a multiple touch, and returns.

Here is what I do:

@override
 public final boolean onTouchEvent(MotionEvent event) {
 if (event.getPointerCount() >= 2) {
            if (!zoomed) {
                zoomed = true;
                drawing.setStarted(false);
            }

            return false;
        }

        if (zoomed && event.getPointerCount() < 2) {
            Log.d("Zoomed", "Drawing");

        }

        if (zoomed) {

            if (event.getAction() == MotionEvent.ACTION_UP) {
                zoomed = false;
            }
            return false;

        }


            float x = event.getX();
            float y = event.getY();

            switch (event.getAction()) {
....
    // here I handle the corresponding event

invalidate();
return true;
}

The question is the following:
How can I draw on canvas, while that is zoomed?

Thanks much in advance!!!

Was it helpful?

Solution

invalidate reschedule the redesign event.

   if (zoomed && event.getPointerCount() < 2) {
        Log.d("Zoomed", "Drawing");
    }

    if (zoomed) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            zoomed = false;
        }
        invalidate();
        return false;

    }

OTHER TIPS

if I understand it right, when you have two fingers on the screen you call

return false;

If you want to trigger drawing, you should call

invalidate();

before that return statement, right?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top