Android accessibility IMPORTANT_FOR_ACCESSIBILITY_NO is not respected
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.
This is what I have done to achieve I have blocked descendant focus-ability which ad view gets by default as it get added to the view last. Wrapping the adview in a layout and adding property.
android:descendantFocusability="blocksDescendants"
My requirement was to assign focus to the first element in screen which I achieved using:
firstView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
firstView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
I still agree to the point we should not change focus but this was only in case of ad. The ad is still focusable by touch.