Android multi-touch development principle

Source: Internet
Author: User
 

Android multi-touch is essentially supported by LCD drivers and programming. Currently, many well-known manufacturers such as HTC, Motorola, and Samsung can support multi-touch Multitouch technology as long as they use capacitive screen touch principles, provides a better user experience for webpage scaling and gesture operations. On the Android platform, events are processed using the MotionEvent object method. For example, when a touch is started, ACTION_DOWN is triggered, and ACTION_UP is triggered when ACTION_MOVE finally releases the finger. Of course, user-less operations may trigger the ACTION_CANCEL action.

First of all, we 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.

In the following example, Android123 uses the Android 2.0 or later SDK to implement multi-touch operations through the application layer. For general control touch operations, the setOnTouchListener () of the View is used internally () the onTouchEvent () method implemented by the interface. For the parameter MotionEvent of the onTouchEvent method, we can process it in detail to understand the multi-touch method. For example

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

More detailed technologies related to Android multi-touch will be discussed in detail in future due to current compatibility and firmware issues. Here we will give you a shot.

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.