为什么 TextView 的对讲文本会读取两次,即使 TextView 已填充,提示也会读取?

ham*_*314 5 android accessibility talkback

我正在做一个大项目,我们使用TextViews 来显示文本和提示。

使用对讲(可访问性)时,我注意到 a 上的提示TextView被读取了两次。

此外,即使 中有文本TextView,提示仍将被读取。

当我使用 an 时EditText,只有第二个问题仍然存在(输入的文本,提示仍被读取)。这似乎是正常的(但令人困惑的)Android 行为,因为像 PlayStore 这样的 Google 应用程序也会这样做。

但是为什么TextView阅读提示两次,而EditText不是?


PS:我知道从 切换TextView到的可能性EditText,但由于我们也在使用自定义视图,这在很大程度上取决于TextView,因此这不是一个可行的选择。

我也知道使用label for,但我对技术背景更感兴趣,为什么TextView阅读提示两次。

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="test"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"/>
Run Code Online (Sandbox Code Playgroud)

无障碍阅读两次

GSu*_*tey 0

它宣布两次,因为您正在为 TextView 设置“提示”,因为它读取自己的文本作为内容描述,并且在没有设置文本时将“提示”用作文本。我认为 TextView 中没有正确处理它。