7.2.4. Processing Multiple Touch Events and Storing Lines in Paths

You can drag one or more fingers across the screen to draw. The app stores the information for each individual finger as a Path object (package android.graphics) that represents line segments and curves. You process touch events by overriding the View method onTouchEvent (Section 7.6). This method receives a MotionEvent (package android.view) that contains the type of touch event that occurred and the ID of the finger (i.e., pointer) that generated the event. We use the IDs to distinguish the different fingers and add information to the corresponding Path objects. We use the type of the touch event to determine whether the user has touched the screen, dragged across the screen ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.