page.title=Multitouch Sample @jd:body

This samples demonstrates the use of

MotionEvent
properties to keep track of individual touches across multiple touch events.

A MotionEvent describes a movement event. 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, reporting all active touches within a single

MotionEvent
.

Each pointer has a unique id that is assigned when it first goes down (indicated by

ACTION_DOWN
or
ACTION_POINTER_DOWN
). A pointer id remains valid until the pointer eventually goes up (indicated by
ACTION_UP
or
ACTION_POINTER_UP
) or when the gesture is canceled (indicated by
ACTION_CANCEL
).

The sample shows how these pointer identifiers can be used over subsequent events to track individual fingers. 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. This example shows the relationship between

MotionEvent
indices, pointer identifiers and
MotionEvent
actions.

For more information, see the relevant blog post and

MotionEvent
API documentation.