Accessibility Check fail when using TextInputLayout

后端 未结 4 1328
Happy的楠姐
Happy的楠姐 2021-01-12 02:32

I\'m using the new TextInputLayout provided by Android.support to do floating label. But it will fail Espresso Accessibility Check because \"View is missing speakable text n

4条回答
  •  梦毁少年i
    2021-01-12 03:00

    A great way to make TextInputLayout accessible is to use "LabelFor" as recommanded by ChrisCM, but you don't have to add an invisible label view to do so: Just put the labelFor or your Textinputlayout and make it point to your EditText

    Example:

    
        
    
    

    This way you get the exact same visual behaviour and make "Espresso Accessibility Check" and Talkback happy :)

    (To make TextInputLayout fully accessible I also added android:accessibilityliveregion on the TextInputLayout element to trigger talkback whenever the error is poping)

    A big thanks to this post this blog post which helped a lot


提交回复
热议问题