Отчет Google о предварительном запуске - несколько элементов имеют одинаковое описание - PullRequest
0 голосов
/ 04 мая 2020

Теперь Google предоставляет «Предварительный отчет», когда новая бета-версия приложения загружается в Play Store. Мои последние предварительные отчеты содержали полный диалог, полный « Несколько элементов имеют одинаковое описание ». Теперь я выяснил, что в моем случае вызвало проблему, и мое решение. Упрощенный макет для моего диалогового окна, который все еще показывает проблему, выглядит следующим образом:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="fill_parent">
   <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical">
      <LinearLayout
         android:id="@+id/displayHeightLayout"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal">
         <TextView
            android:id="@+id/displayHeightLbl"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="@string/displayInfoEms"
            android:labelFor="@id/displayHeight"
            android:text="@string/displayHeightLbl" />
        <TextView
                android:id="@+id/displayHeight"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="@string/displayInfoEms" />
      </LinearLayout>
      <Button
         android:id="@+id/displayInfoOkBtn"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:onClick="dismissDisplayInfos"
         android:text="@string/btnOk" />
   </LinearLayout>
</ScrollView>

В документации Google предлагается установить TalkBack и сканер доступности, что позволило мне протестировать и воспроизвести проблему. Решение описано ниже.

1 Ответ

0 голосов
/ 04 мая 2020

Решение заключается в добавлении

android:importantForAccessibility="no"

к определению второго TextView следующим образом:

        <TextView
                android:id="@+id/displayHeight"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:importantForAccessibility="no"
                android:ems="@string/displayInfoEms" />

Я предполагаю, что причиной отчета является то, что первый TextView содержит атрибут android:labelFor, относящийся ко второму TextView, и что Сканер доступности просматривает оба и считает, что описания одинаковы. Это ошибка сканера доступности?

...