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.
When using an ImageView , ImageButton , CheckBox , or other View that conveys information graphically, use an android:contentDescription attribute to provide a content label for that View . A content label sometimes depends on information only available at runtime, or the meaning of a View might change over time.
Getting Started. Enabling TalkBack: Go to Settings > Accessibility > TalkBack to turn on TalkBack. To activate the TalkBack shortcut, go to Settings > Accessibility and turn on the Volume Key Shortcut. You can then hold the volume keys for a few seconds to turn TalkBack on or off.
Editable items in an app allow users to enter text. Each editable item should have a descriptive label stating its purpose. Android offers several ways for developers to label Views in an app's user interface. For editable items in an interface, some of these ways of labeling can improve accessibility.
More details: if you are strictly interested in whether TalkBack is enabled, use am. isTouchExplorationEnabled() . (If Select to Speak is enabled and TalkBack disabled, am. isEnabled() will still return true.)
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"/>
According to the official documentation, you shouldn't be setting android:contentDescription
equal to anything. Instead, only use android:hint
.
<EditText
android:id="@+id/extUsername"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Username" />
"field" from your contentDescription
should be removed, because TalkBack will announce it as "Username edit box"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With