user3678711
user3678711

Reputation: 17

Is there any way to draw on canvas, when that is zoomed?


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!!!

Upvotes: 0

Views: 86

Answers (2)

tomorrow
tomorrow

Reputation: 1378

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?

Upvotes: 1

Blackbelt
Blackbelt

Reputation: 157437

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;

    }

Upvotes: 1

Related Questions