使用轻触手势
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
试用 Compose 方式
Jetpack Compose 是推荐在 Android 设备上使用的界面工具包。了解如何在 Compose 中使用触控和输入功能。
本文档介绍了如何编写可让用户使用轻触手势与应用互动的应用。Android 提供了多种 API 来帮助您创建和检测手势。
尽管您的应用不得依赖轻触手势来执行基本行为(因为手势可能并非适用于所有上下文环境),但向应用添加基于轻触的互动可以极大地提升其实用性和吸引力。
为了向用户提供一致、直观的体验,应用必须遵循公认的 Android 轻触手势规范。Material Design 手势文档介绍了如何在 Android 应用中使用常用手势。另请参阅 Material 运动。
如需详细了解此主题,请参阅以下相关指南:
主题
-
检测常用手势
-
了解如何使用
GestureDetector
检测基本触摸手势,例如滚动、滑动和点按两次。
-
跟踪轻触和指针移动
-
了解如何跟踪动作。
-
以动画方式显示滚动手势
-
了解如何使用滚动条(
Scroller
或 OverScroller
)生成滚动动画以响应轻触事件。
-
处理多点触控手势
-
了解如何检测多指针(手指)手势。
-
拖动并缩放
-
了解如何实现基于轻触的拖动和缩放。
- 在 ViewGroup 中管理触摸事件
- 了解如何在
ViewGroup
中管理触摸事件,以确保触摸事件正确分派给其目标视图。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[],[],null,["# Use touch gestures\n\nTry the Compose way \nJetpack Compose is the recommended UI toolkit for Android. Learn how to use touch and input in Compose. \n[Gestures →](/jetpack/compose/touch-input/pointer-input) \n\nThis document describes how to write apps that let users interact with an app using touch\ngestures. Android provides a variety of APIs to help you create and detect gestures.\n\nAlthough your app must not depend on touch gestures for basic behaviors---since the gestures\nmight not be available to all users in all contexts---adding touch-based interaction to your app\ncan greatly increase its usefulness and appeal.\n\nTo provide users with a consistent, intuitive experience, your app must follow the accepted\nAndroid conventions for touch gestures. The\n[Material Design Gestures](https://material.io/design/interaction/gestures.html)\ndocument shows you how to use common gestures in Android apps. Also, see\n[Material Motion](https://material.io/guidelines/motion/material-motion.html).\n\nFor more information about this topic, read the following related guides:\n\n- [Input events overview](/guide/topics/ui/ui-events)\n- [Sensors overview](/guide/topics/sensors/sensors_overview)\n- [Make a custom view\n interactive](/training/custom-views/making-interactive)\n\nTopics\n------\n\n\n**[Detect common gestures](/develop/ui/views/touch-and-input/gestures/detector)**\n:\n Learn how to detect basic touch gestures, such as scrolling, flinging, and double-tapping,\n using\n [GestureDetector](/reference/android/view/GestureDetector).\n\n\n**[Track touch and pointer movements](/develop/ui/views/touch-and-input/gestures/movement)**\n:\n Learn how to track movement.\n\n\n**[Animate a scroll gesture](/develop/ui/views/touch-and-input/gestures/scroll)**\n:\n Learn how to use\n scrollers---[Scroller](/reference/android/widget/Scroller)\n or\n [OverScroller](/reference/android/widget/OverScroller)---to\n produce a scrolling animation in response to a touch event.\n\n\n**[Handle multi-touch gestures](/develop/ui/views/touch-and-input/gestures/multi)**\n:\n Learn how to detect multi-pointer (finger) gestures.\n\n\n**[Drag and scale](/develop/ui/views/touch-and-input/gestures/scale)**\n:\n Learn how to implement touch-based dragging and scaling.\n\n**[Manage touch events in a ViewGroup](/develop/ui/views/touch-and-input/gestures/viewgroup)**\n: Learn how to manage touch events in a\n [ViewGroup](/reference/android/view/ViewGroup) to ensure that\n touch events are correctly dispatched to their target views."]]