Reputation: 3981
I am adding accessibility to an app and I am using google's talkback for testing accessibility and I am unable to block certain views from being selected.
Besides removing all listeners and focusability, is there any better way to disable views from obtaining focus when they are hidden on the screen... ie having a "drawer" open and disabling the selection of items in the content container? It seems like there should be a cleaner solution to this or maybe a fix is required on the talkback team's side.
Thanks
Upvotes: 3
Views: 6149
Reputation: 51581
Look into AccessibilityDelegateCompat
available in support-v4 library - Link.
Create an instance of AccessibilityDelegateCompat
and override the following method:
@Override
public void onInitializeAccessibilityNodeInfo(View host,
AccessibilityNodeInfoCompat info) {
// Check if 'host' is visible or not before calling the super method
if (host.getVisibility() != View.INVISIBLE) {
super.onInitializeAccessibilityNodeInfo(host, info);
}
}
Finally, use static method ViewCompat.setAccessibilityDelegate(View, AccessibilityDelegateCompat)
for the views that are invisible.
Upvotes: 3