Nhập con trỏ trong Compose
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Compose cung cấp một loạt API giúp bạn phát hiện các cử chỉ tạo ra khi người dùng tương tác. Có nhiều trường hợp sử dụng cho những API này:
Một vài trong số đó là API cấp cao và được thiết kế để xử lý những cử chỉ được sử dụng phổ biến nhất. Ví dụ: đối tượng sửa đổi (modifier) clickable
giúp dễ dàng phát hiện một lượt nhấp, đồng thời cung cấp các tính năng hỗ trợ tiếp cận và hiển thị chỉ báo bằng hình ảnh khi người dùng nhấn vào (chẳng hạn như hiệu ứng gợn sóng).
Ngoài ra, còn có các trình phát hiện cử chỉ ít được sử dụng và không có tính năng bổ sung nhưng mang lại sự linh hoạt cao hơn ở cấp độ thấp hơn như PointerInputScope.detectTapGestures
hoặc PointerInputScope.detectDragGestures
.
Tìm hiểu thêm về phương thức nhập con trỏ trên các trang sau:
- Bài viết Tìm hiểu về cử chỉ giải thích các khái niệm chính có vai trò quan trọng khi xử lý phương thức nhập bằng con trỏ.
- Tuỳ chọn Chạm và nhấn mở rộng đối với các sự kiện con trỏ đơn, sự kiện một vị trí.
- Scroll (Cuộn) giải thích cách triển khai vùng chứa cuộn và xử lý các vấn đề về khả năng tương tác.
- Kéo, vuốt và hất cho thấy các thao tác kéo khác nhau của một con trỏ duy nhất.
- Chế độ cảm ứng đa điểm chuyên phân tích các trường hợp sử dụng nhiều con trỏ.
Đề xuất cho bạn
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# Pointer input in Compose\n\nCompose provides a variety of APIs to help you detect gestures that are\ngenerated from user interactions. The APIs cover a wide range of use cases:\n\n- Some of them are **high-level** and designed to cover the most commonly used\n gestures. For example, the\n [`clickable`](/reference/kotlin/androidx/compose/foundation/package-summary#(androidx.compose.ui.Modifier).clickable(kotlin.Boolean,kotlin.String,androidx.compose.ui.semantics.Role,kotlin.Function0))\n modifier allows easy\n detection of a click, and it also provides accessibility features and\n displays visual indicators when tapped (such as ripples).\n\n- There are also less commonly used gesture detectors that offer more\n flexibility on a **lower level** , like\n [`PointerInputScope.detectTapGestures`](/reference/kotlin/androidx/compose/foundation/gestures/package-summary#(androidx.compose.ui.input.pointer.PointerInputScope).detectTapGestures(kotlin.Function1,kotlin.Function1,kotlin.coroutines.SuspendFunction2,kotlin.Function1)) or\n [`PointerInputScope.detectDragGestures`](/reference/kotlin/androidx/compose/foundation/gestures/package-summary#(androidx.compose.ui.input.pointer.PointerInputScope).detectDragGestures(kotlin.Function1,kotlin.Function0,kotlin.Function0,kotlin.Function2))\n but don't include the extra features.\n\nLearn more about pointer input on the following pages:\n\n- [Understand gestures](/develop/ui/compose/touch-input/pointer-input/understand-gestures) gives an explanation of the core concepts playing a role when handling pointer input.\n- [Tap and press](/develop/ui/compose/touch-input/pointer-input/tap-and-press) expands on single pointer, single position events.\n- [Scroll](/develop/ui/compose/touch-input/pointer-input/scroll) explains how to implement scrolling containers, and handles interoperability concerns.\n- [Drag, swipe, and fling](/develop/ui/compose/touch-input/pointer-input/drag-swipe-fling) shows different types of dragging of a single pointer.\n- [Multi-touch](/develop/ui/compose/touch-input/pointer-input/multi-touch) dives into situations where more than one pointer is used.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Enable user interactions](/develop/ui/compose/text/user-interactions)\n- [Semantics in Compose](/develop/ui/compose/semantics)\n- [Compose modifiers](/develop/ui/compose/modifiers)"]]