Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android accessibility in edit text with hint

I have edittext for entering first name when creating account and its hint is "Jane"(as first name). I also want to have content description on this edittext for accessibility saying "first name". When I set both hint and content description warning pops up "Do not set both contentDescription and hint: the contentDescription will mask the hint" and this is fine, it's just that content description doesn't mask hint. When I turn on TalkBack it still reads hint and not content description.

Could anyone help me with this. Thnx.

like image 255
Damir Avatar asked Oct 07 '13 12:10

Damir


People also ask

How do I use hint on android?

To label an editable TextView or EditText , use android:hint to display a descriptive text label within the item when it's empty. If an app's user interface already provides a text label for the editable item, define android:labelFor on the labeling View to indicate which item the label describes.

How do you use editable text on android?

If you set android:editable="true" you can access the TextView via the D-pad, or you could add android:focusableInTouchMode="true" to be able to gain focus on touch. The problem is you cannot modify the existing text, and you cannot move the cursor. The text you write just gets added before the existing text.

How do you set different gravity for TextInputLayout hint and text in android?

To set a different gravity for the EditText , don't set any gravity attributes in the layout, then set the EditText 's gravity programmatically, in your code. That is, after setContentView() , use findViewById() to get the EditText , then call setGravity(Gravity. CENTER_HORIZONTAL) on it.


1 Answers

From what I understand, android:hint is meant as a placeholder for text in TextViews (and its subclasses) as long as they do not display any text, whereas android:contentDescription is meant as alternative textual description for non-textual content (images...). Therefore I'd set hint on the EditText only.

like image 108
Hans Hohenfeld Avatar answered Sep 17 '22 17:09

Hans Hohenfeld