首页 > 解决方案 > RecyclerView 中延迟加载子项的 RecyclerView 可访问性遍历

问题描述

我们可以用项目填充 a RecyclerView,并且在绑定时,我们可以将其中一些项目标记为“标题”以方便访问。

这意味着在 TalkBack 的“标题”遍历模式下,用户可以直接在它们之间导航。

但是,aRecyclerView在滚动时显然会绑定和取消绑定子项。在任何时候,可能只有总标题项的一小部分加载到视图持有者中。仅在这些项目之间进行遍历是无益且令人困惑的。

有没有办法,甚至是最佳实践,来提供RecyclerView我们同时满足(a)性能视图回收和(b)有意义的遍历整个内容集的可访问性?

标签: androidandroid-recyclerviewaccessibilityandroid-accessibilityandroid-a11y

解决方案


Not all of the items considered headings in your source data set will be visibly present in the RecyclerView at any one time, just those in the current subset of the data presented by the RecycleView.Adapter. Without being visible on screen, accessibility services like TalkBack don't have access to those other headings and therefore will not interact with them.

Technically, you could look at setting up custom handling of the accessibility tree, but this would need to handle all accessibility info for the view, not just the headings, and would likely impact performance especially for large data sets. There is no way to override the heading handling alone.

The behaviour your describe is default and expected behaviour on Android, even if it doesn't seem ideal from a screen reader user experience perspective.


推荐阅读