Dependencies and prerequisites
- Android 1.6 (API Level 4) or higher
You should also read
- Input Events API Guide
- Sensors Overview
- Making the View Interactive
- Design Guide for Gestures
- Design Guide for Touch Feedback
Try it out
Download the sample
InteractiveChart.zip
This class describes how to write apps that allow users to interact with an app via touch gestures. Android provides a variety of APIs to help you create and detect gestures.
Although your app should not depend on touch gestures for basic behaviors (since the gestures may not be available to all users in all contexts), adding touch-based interaction to your app can greatly increase its usefulness and appeal.
To provide users with a consistent, intuitive experience, your app should follow the accepted Android conventions for touch gestures. The Gestures design guide shows you how to use common gestures in Android apps. Also see the Design Guide for Touch Feedback.
Lessons
- Detecting Common Gestures
-
Learn how to detect basic touch gestures such as scrolling, flinging, and double-tapping, using
GestureDetector
. - Tracking Movement
- Learn how to track movement.
- Animating a Scroll Gesture
-
Learn how to use scrollers (
Scroller
orOverScroller
) to produce a scrolling animation in response to a touch event. - Handling Multi-Touch Gestures
- Learn how to detect multi-pointer (finger) gestures.
- Dragging and Scaling
- Learn how to implement touch-based dragging and scaling.
- Managing Touch Events in a ViewGroup
- Learn how to manage touch events in a
ViewGroup
to ensure that touch events are correctly dispatched to their target views.