简体   繁体   中英

talkback is announcing hidden views

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM