使用觸控手勢
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
試用 Compose
Jetpack Compose 是 Android 推薦的 UI 工具包。瞭解如何在 Compose 中使用觸控和輸入功能。
本文件說明如何編寫應用程式,讓使用者透過觸控手勢與應用程式互動。Android 提供多種 API,可協助您建立和偵測手勢。
雖然您的應用程式不得依賴觸控手勢來執行基本行為,因為並非所有情境的使用者都能使用手勢,但在應用程式中新增以觸控為基礎的互動,可能會大幅提升應用程式實用性和吸引力。
為了讓使用者享有一致且直覺的體驗,應用程式必須遵循可接受的 Android 觸控手勢慣例。Material Design 手勢文件說明如何在 Android 應用程式中使用常用手勢。另請參閱 Material 動態。
如要進一步瞭解這個主題,請參閱下列相關指南:
主題
-
偵測常用手勢
- 瞭解如何使用
GestureDetector
偵測基本的觸控手勢,例如捲動、快速滑過和輕觸兩下。
-
追蹤觸控和指標移動位置
- 瞭解如何追蹤動作。
-
為捲動手勢建立動畫
-
瞭解如何使用捲動器 (
Scroller
或 OverScroller
),產生回應觸控事件的捲動動畫。
-
處理多點觸控手勢
- 瞭解如何偵測多指標 (手指) 手勢。
-
拖曳及縮放
-
瞭解如何實作輕觸式拖曳和縮放功能。
- 管理 ViewGroup 中的觸控事件
- 瞭解如何管理
ViewGroup
中的觸控事件,確保觸控事件可正確發送至目標檢視畫面。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間: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."]]