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.
Kiểm tra
Có một số công cụ có thể giúp bạn nhanh chóng kiểm tra nội dung của mình theo góc độ hỗ trợ tiếp cận:
Bộ hỗ trợ tiếp cận của Android: Bao gồm Trình đơn hỗ trợ tiếp cận, tính năng Chọn để nói,
Tiếp cận bằng công tắc và TalkBack. Các tính năng này cung cấp thông tin chi tiết về cách ngữ nghĩa của
ứng dụng hoạt động đối với người dùng các công nghệ này. Bạn nên kiểm thử bằng các công nghệ hỗ trợ của Android vì đây là cách tốt nhất để hiểu được trải nghiệm của người dùng có nhu cầu hỗ trợ tiếp cận.
Layout Inspector (Trình kiểm tra bố cục): Cho phép bạn kiểm tra và gỡ lỗi ngữ nghĩa của từng thành phần kết hợp, đồng thời giúp xác định mọi thông tin bị thiếu hoặc không chính xác.
Ứng dụng Trình quét hỗ trợ tiếp cận: Quét màn hình và đưa ra đề xuất để cải thiện khả năng hỗ trợ tiếp cận bằng cách xác định một số lỗi thường gặp.
Gỡ lỗi
Giữa Compose, hệ thống ngữ nghĩa và các dịch vụ hỗ trợ tiếp cận của Android, bạn có thể gặp phải các hành vi hỗ trợ tiếp cận không mong muốn và khó theo dõi.
Thuộc tính ngữ nghĩa có thể giúp bạn hiểu lý do các thành phần của mình hoạt động như vậy.
Bạn có thể gỡ lỗi các vấn đề về hành vi hỗ trợ tiếp cận bằng Layout Inspector (Trình kiểm tra bố cục) trong Android Studio, TreeDebug trong phần cài đặt dành cho nhà phát triển TalkBack hoặc printToLog của ComposeTestRule. Tất cả các công cụ này đều có thể cung cấp thông tin về các nút (và thuộc tính của các nút đó) được Compose hiển thị cho các dịch vụ hỗ trợ tiếp cận.
Ví dụ sau sử dụng Layout Inspector để gỡ lỗi một màn hình có 3 phần tử, trong đó khi bật dịch vụ hỗ trợ tiếp cận, phần tử đầu tiên không được chọn và phần tử thứ hai không có phản hồi hành động nào liên kết với phần tử đó. Bạn có thể kiểm tra các thuộc tính ngữ nghĩa để tìm các vấn đề tiềm ẩn.
Cây thành phần trong Layout Inspector chứa thông tin về giới hạn, tham số và thông tin ngữ nghĩa khác liên kết với một phần tử. Trong cây, cả ba phần tử đều được nhận dạng:
Hình 2. Layout Inspector với cả ba phần tử..
Phần tử đầu tiên đã áp dụng thuộc tính hideFromAccessibility. Điều này cho biết phần tử có thể được đánh dấu là ẩn ở đâu đó trong cây ngữ nghĩa hoặc bị che khuất bởi một số lớp phủ trang trí.
Hình 3. Layout Inspector: phần tử đầu tiên có hideFromAccessibility.
Phần tử thứ hai có thuộc tính tiêu điểm nhưng không có onClick như phần tử trước. Do đó, có thể thiếu một đối tượng sửa đổi clickable ở đâu đó, đó là lý do một dịch vụ hỗ trợ tiếp cận như TalkBack có thể không thông báo một số tín hiệu hành động cho người dùng:
Hình 4. Layout Inspector: phần tử thứ hai có focused.
Phần tử văn bản thứ ba có tất cả các thuộc tính cần thiết – có thể lấy tiêu điểm, có onClick và các ngữ nghĩa bổ sung khác được áp dụng – đó là lý do tại sao phần tử này được diễn giải như mong đợi.
Hình 5. Layout Inspector: phần tử thứ ba với tất cả API.
Bằng cách này, bạn có thể sử dụng các công cụ gỡ lỗi để điều tra lý do một số thông báo hoặc lựa chọn nhất định không được các dịch vụ hỗ trợ tiếp cận thực hiện.
Đề xuất cho bạn
Lưu ý: văn bản có đường liên kết sẽ hiện khi JavaScript tắt
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.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# Inspect and debug\n\nInspect\n-------\n\nSeveral tools can help you quickly inspect your content from an accessibility\npoint of view:\n\n- [Android Accessibility Suite](https://play.google.com/store/apps/details?id=com.google.android.marvin.talkback): Includes Accessibility Menu, Select to Speak, Switch Access, and TalkBack, which provide insight into how your app's semantics work for users of these technologies. Testing with Android's assistive technologies is highly recommended as the best way to understand what your users with accessibility needs will experience.\n- [Layout Inspector](/develop/ui/compose/tooling/debug#layout_inspector): Lets you inspect and debug semantics of each composable, and helps identify any missing or incorrect information.\n- [Accessibility Scanner](https://support.google.com/accessibility/android/answer/6376570) app: Scans your screen and provides suggestions to improve its accessibility by identifying some common pitfalls.\n\nDebug\n-----\n\nBetween Compose, the semantics system, and Android accessibility services, you\nmight run into unexpected accessibility behaviors that are difficult to trace.\nSemantic properties can help you understand why your components are behaving\nthe way that they are.\n\nYou can debug accessibility behavior issues with the [Layout Inspector](/develop/ui/compose/tooling/debug#layout_inspector) in\nAndroid Studio, TreeDebug in TalkBack developer settings, or `ComposeTestRule`'s\n[`printToLog`](/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).printToLog(kotlin.String,kotlin.Int)). All of these tools can provide information about nodes\n(and their properties) that are exposed to accessibility services by Compose.\n\nThe following example uses Layout Inspector to debug a screen with three\nelements where, with accessibility services on, the first one isn't being\nselected, and the second one doesn't have any action feedback associated with\nit. You can examine the semantic properties to find potential issues.\n\nThe component tree in Layout Inspector contains information about an element's\nbounds, parameters, and other semantic information associated with it. In the\ntree, all three elements are recognized:\n**Figure 2.** Layout Inspector with all three elements..\n\nThe first element has the `hideFromAccessibility` property applied. This\nindicates that the element may be marked as hidden somewhere in the semantics\ntree, or it is obscured by some decorative overlay.\n**Figure 3.** Layout Inspector: first element with `hideFromAccessibility`.\n\nThe second element has a focus property, but no `onClick` like the previous\nelement. Therefore, it might be missing a `clickable` modifier somewhere, which\nis why an accessibility service like TalkBack may not be announcing some\naction signal to the user:\n**Figure 4.** Layout Inspector: second element with `focused`.\n\nThe third text element has all the necessary properties---it is focusable, has\nan `onClick`, and other additional semantics applied---which is why it's\ninterpreted as expected.\n**Figure 5.** Layout Inspector: third element with all APIs.\n\nIn this way, you can use debugging tools to investigate why certain\nannouncements or selections aren't performed by accessibility services.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Accessibility in Compose](/develop/ui/compose/tooling/debug#layout_inspector)\n- \\[Material Design 2 in Compose\\]\\[19\\]\n- [Testing your Compose layout](https://support.google.com/accessibility/android/answer/6376570)"]]