Android accessibility IMPORTANT_FOR_ACCESSIBILITY_NO is not respected

SCP picture SCP · Sep 16, 2015 · Viewed 10.6k times · Source

In my app I have ad on bottom, in accessibility (talkback) mode I don't want ads to be included. for this I have set this AdView and its parent to IMPORTANT_FOR_ACCESSIBILITY_NO and focusable = false, but it is not respected when app starts (Talkback enabled)the first item that gets focused is this ad.

I request focus to desired item still ad is focused, how can I make this ad not focusable?

Answer

ChrisCM picture ChrisCM · Sep 17, 2015

When you set importantForAccessibility to no, you're only hiding the single view. You want to find the layout for the advertisement, and hide it and all of its descendants.

android:importantForAccessibility="noHideDescendants"

Should you want to do it programmatically, the constant you are looking for is:

IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS

Note: YOU ABSOLUTELY SHOULD NOT, do this. Advertisements are annoying for everyone. Separate is not equal. By hiding information, even annoying information, from VoiceOver you are breaking at least half a dozen WCag 2.0 criteria and making your application less accessible.