Android feeling 02 -- Android multi-touch

Source: Internet
Author: User

In Android, multi-touch is a very interesting technology. multi-touch can make your game more playable. First, let's talk about how to implement multi-touch.

Event. getaction () // obtain touch actions such as action_down

Event. getpointercount (); // obtain the number of touch points. For example, if 2 is used, two fingers may simultaneously press the screen.

Event. getpointerid (NID); // For the details of each touch point, we can obtain the index by executing the getpointerid method in a loop.

Event. getx (NID); // obtain the X position of the NID touch point

Event. Gety (NID); // obtain the Y position of the NID point.

Event. getpressure (NID); // LCD can sense the user's finger pressure. Of course, the specific level is determined by the driver and physical hardware.

Event. getdowntime () // Press Start Time

Event. geteventtime () // event end time

Event. geteventtime ()-event. getdowntime (); // it takes a long time to press

Events on the Android platform can be processed using the motionevent object method. When the touch starts, action_down is triggered, while action_move is performed, and action_up is triggered when the finger is released. Of course, user-less operations may trigger the action_cancel action.

How can I use the application layer to support multi-touch operations? For general control touch operations, the setontouchlistener () interface of the view is internally implemented and the ontouchevent () method is implemented. For the parameter motionevent of the ontouchevent method, we can process it in detail to implement multi-touch.

I would like to remind you that multi-touch operations can only be achieved through LCD driver and application software, for example, mobile phones that were previously Android 2.1 or listed in North America may not support multi-touch firmware, due to Apple's patent, new firmware models after Android 2.1 in Europe and Asia Pacific have been supported in screen drivers, and the simulator cannot perform multi-touch testing.

Related Article

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.