10

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?

Anggrayudi H
  • 14,977
  • 11
  • 54
  • 87
SCP
  • 153
  • 1
  • 2
  • 10

3 Answers3

22

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.

Ryan M
  • 18,333
  • 31
  • 67
  • 74
MobA11y
  • 18,425
  • 3
  • 49
  • 76
  • Hi @ChrisCM, I am working on android app to make it accessible, I am new to accessibility and facing issue in implementation, I have posted another question here : [link](http://stackoverflow.com/questions/32570120/android-webview-do-not-scroll-down-accessibility-marker) hope you can help me on that Thanks – SCP Sep 17 '15 at 15:16
  • 3
    Disagree with statement of not doing this (but I agree with the sentiment) - AdView is outside of your app's control and last I checked, it's not accessible using TalkBack (no content description). I think it's reasonable and proper to hide it. – ataulm Mar 07 '16 at 15:52
  • If there is no accessible content within an elemet where "descendants" have been hidden, the result will be the same as if they weren't hidden. If there are accessible elements within, then we have clearly hidden some content from the user. The only times we want to do this, is when this content is also hidden visually, however, the accessibility APIs still have access to it because you decided to hide it in a stupid way (EX: making it clear colored). That is the only exception I have found. I'm open to others, however, your example is certainly not one of them. – MobA11y Mar 07 '16 at 16:51
2

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.

1

Straight from docs

android:importantForAccessibility Describes whether or not this view is important for accessibility. If it is important, the view fires accessibility events and is reported to accessibility services that query the screen. Note: While not recommended, an accessibility service may decide to ignore this attribute and operate on all views in the view tree.

though that note makes no sense by itself: what is not recommended and by or to whom? but probably means that this feature may not be taken into account by actual accessibility services (Talkback etc). It does not work in API23 but does work in 26 on webviews, from my experience.

Boris Gafurov
  • 1,427
  • 16
  • 28