我有一个 ScrollView,里面有多个 TextView(默认情况下不可聚焦)。当我使用 TalkBack 浏览屏幕时,TalkBack 仅聚焦整个 ScrollView 并立即读取其所有内容。
我尝试了一些方法来使 TalkBack 聚焦每个 TextView 而不是 ScrollView 容器,但我找不到一个好的方法来做到这一点。这是示例代码:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/string"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/a_string"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/some_string"/>
</LinearLayout>
</ScrollView>
我尝试将 android:focusable=true
添加到每个 TextView,这使得它们可以通过 TalkBack 获得焦点,但父 ScrollView 仍然首先获得焦点。理想情况下,我希望 TalkBack 完全忽略 ScrollView,并且焦点直接转到其 subview 。
如何让 TalkBack 完全忽略 ScrollView 并逐一聚焦每个子 TextView?
最佳答案
您可以在 ScrollView 上使用 android:importantForAccessibility="no"
让 Talkback 绕过 rootview 并直接迭代 subview
关于android - ScrollView 通过对讲而不是其子 TextView 获得焦点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40368103/