There is a motionevent parameter in the TouchEvent event, so here's a brief introduction to some of the implications of its properties and how to use it
Generally, a single finger operation is generally as follows:
Switch (event.getaction ()) {//First touch point case motionevent.action_down: //press = 0<span style= "White-space:pre" > float x = Event.getx (); </span>break;case motionevent.action_move: //move = 2break;case motionevent.action_up: //lift = 1break;}
When multi-touch:
The following properties appear at API level 5 and API Level 8 is obsolete.
Motionevent.action_pointer_1_down
Motionevent.action_pointer_2_down
Motionevent.action_pointer_3_down
Motionevent.action_pointer_1_up
Motionevent.action_pointer_2_up
Motionevent.action_pointer_3_up
API Level 8 is 2.2 after: Motionevent.action_pointer_downmotionevent.action_pointer_up
The following tests found that when a single touch
Switch (event.getaction ()) {//case Motionevent.action_down://press = 0//SYSTEM.OUT.PRINTLN ("ontouchevent");//break;// Case motionevent.action_move://move = 2////break;//case motionevent.action_up://lift = 1////break;case MotionEvent.ACTION _pointer_down://not the first touch point press = 5system.out.println ("Action_pointer_down"); Break;case Motionevent.action_pointer _UP://Not first touch point lifted = 6system.out.println ("action_pointer_up"); break;default:break;}
motionevent.action_pointer_downmotionevent.action_pointer_upNot executed
The second point takes the x, Y coordinate values
float x2 = event.getx (Event.getactionindex ());//action index starts from 0 to pointer count-1 end float y2 = event.gety (event.getactio NIndex ());//The y-coordinate of the touch point of an index relative to the current view Event.getpointercount (); Number of touch points