Android TalkBack: Hint overwrites contentDescription

Egemen Hamutçu picture Egemen Hamutçu · Apr 27, 2015 · Viewed 10.4k times · Source

I have an EditText like below

<EditText
    android:id="@+id/extUsername"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:contentDescription="Username field"
    android:hint="Username" />

I want TalkBack to say "Username field" but it says "Username". It ignores contentDescription.

Do not tell me to remove hint or contentDescription. I need to use both.

Any advices will be appreciated.

Answer

ChrisCM picture ChrisCM · Jun 11, 2015

What you want to do is use LabelFor instead. LabelFor allows a visual label to be associated with an EditText box. You can make the visual label invisible if you'd like, so that it doesn't change your visual layout.

The down side to hints, is that they disappear after text is entered, making them pretty poor accessibility tools. If you're relying on hints for your Accessibility information, your app is not accessible.

Do something like this:

<TextView
     android:text="@string/yourEditTextDescription"
     android:labelFor="@+id/editTextField" />

<EditText android:id="@+id/editTextField"/>