1 page.title=Multitouch Sample 2 @jd:body 3 4 <p>This samples demonstrates the use of <pre>MotionEvent</pre> properties to keep track of individual touches across multiple touch events.</p> 5 6 <p>A <a href="http://developer.android.com/reference/android/view/MotionEvent.html">MotionEvent</a> describes a movement event. 7 For touch events, they contain an action, X and Y coordinates and other relevant information. Multi-touch screens can report multiple movement traces at the same time, 8 reporting all active touches within a single <pre>MotionEvent</pre>.</p> 9 10 <p>Each pointer has a unique id that is assigned when it first goes down 11 (indicated by <pre><a href="/reference/android/view/MotionEvent.html#ACTION_DOWN">ACTION_DOWN</a></pre> or <pre><a href="/reference/android/view/MotionEvent.html#ACTION_POINTER_DOWN">ACTION_POINTER_DOWN</a></pre>). A pointer id 12 remains valid until the pointer eventually goes up (indicated by <pre><a href="/reference/android/view/MotionEvent.html#ACTION_UP">ACTION_UP</a></pre> 13 or <pre><a href="/reference/android/view/MotionEvent.html#ACTION_POINTER_UP">ACTION_POINTER_UP</a></pre>) or when the gesture is canceled (indicated by 14 <pre><a href="/reference/android/view/MotionEvent.html#ACTION_CANCEL">ACTION_CANCEL</a></pre>). 15 </p> 16 17 <p>The sample shows how these pointer identifiers can be used over subsequent events to track individual fingers. 18 This is illustrated by a custom View that responds to touch events. Coloured circles are drawn for each finger, showing its current and past position on the screen. 19 This example shows the relationship between <pre>MotionEvent</pre> indices, pointer identifiers and <pre>MotionEvent</pre> actions.</p> 20 21 <p>For more information, see the relevant <a href="http://android-developers.blogspot.com.au/2010/06/making-sense-of-multitouch.html">blog post</a> and 22 <a href="http://developer.android.com/reference/android/view/MotionEvent.html"><pre>MotionEvent</pre></a> API documentation. </p> 23 24 <p><img src="images/MultitouchSample.png" /></p> 25