Android Multi-Touch summary

Source: Internet
Author: User

The article is part of the content reference:

http://blog.csdn.net/barryhappy/article/details/7392326

Summarize:

1. event.getx () can get the coordinates of x , the parameter 0 inside indicates the first touch; 1 indicates a second touch point;

2. motionevent.action_down: Triggered when the first point is pressed

3. motionevent.action_up: triggers when the only point on the screen is released

4. If the index finger touches the screen first, it will trigger the action_down, then lift the action_up, and If the index finger touches the screen first, The middle finger then touches the screen, the middle finger triggers the action_pointer_2_down, andthen the lifted finger triggers action_pointer_2_up(in this case, Whether it is the index finger or the middle finger lifted up), and then, may press and lift again, the trigger is action_pointer_1_down and Action_pointer_1_down .

@SuppressWarnings ("Deprecation")     Public Booleanontouchevent (Motionevent event) {intAction =event.getaction (); if(Event.getpointercount () = = 2) {x1= Event.getx (1); Y1= Event.gety (1); } x0= Event.getx (0); Y0= Event.gety (0); Switch(action) { CaseMotionEvent.ACTION_DOWN:HandleDown (Getarea (x0, y0));  Break;  CaseMotionEvent.ACTION_UP:HandleUp (Getarea (x0, y0));  Break; //when you press two places, lift the 1th one and press again to trigger the Action_pointer_1_down         CaseMotionEvent.ACTION_POINTER_1_DOWN:HandleDown (Getarea (x0, y0));  Break;  CaseMotionEvent.ACTION_POINTER_1_UP:HandleUp (Getarea (x0, y0));  Break;  CaseMotionEvent.ACTION_POINTER_2_DOWN:HandleDown (Getarea (x1, y1));  Break;  CaseMotionEvent.ACTION_POINTER_2_UP:HandleUp (Getarea (x1, y1));  Break; }                return Super. Ontouchevent (event); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.