I want to process a gesture in my activity. To do this, I override the public boolean onTouchEvent (MotionEvent MEvent) method in my work. The content is as follows:
motionaction = MEvent.getAction(); if(motionaction == MotionEvent.ACTION_DOWN) { ... return true; } if(motionaction == MotionEvent.ACTION_UP) { ... return true; } if(motionaction == MotionEvent.ACTION_MOVE) { ... return true; } motionaction = MEvent.getActionMasked(); if(motionaction == MotionEvent.ACTION_POINTER_DOWN) { ... return true; } if(motionaction == MotionEvent.ACTION_POINTER_UP) { ... return true; } return true;
Gesture of this:
-finger1 on the screen holds its position (almost because there is always a slight movement)
-finger2 moves around the screen. This is the movement that I want to capture.
I can capture action 5, but the problem is that when two fingers are on the screen, ACTION_MOVE captures the movement of both the first and second fingers. The MEvent.getActionIndex () method does not work for ACTION_MOVE, which always returns 0; The only thing I can do is to maintain the position of finger1 and discard the movement near this point. As a result, this is not the ideal movement of the finger2 once, which it “ruined” with the movement of the small finger1, because although the finger holds its position on the screen, the listener feels every minimal movement.
How can I improve this?
source share