Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feedback] [Native Android] - Button #20

Open
a11yjc opened this issue Apr 4, 2022 · 0 comments
Open

[Feedback] [Native Android] - Button #20

a11yjc opened this issue Apr 4, 2022 · 0 comments

Comments

@a11yjc
Copy link

a11yjc commented Apr 4, 2022

Hiya, firstly - awesome resource! It's really useful. 😀

I've noticed within the Acceptance Criteria for Buttons within Android that "Double tap to activate" is enough to signify the role. However, this is a usage hint which can be turned off within Talkback settings by the user. I therefore propose an update to the guidance to reflect that setRoleDescription or setClassName as a way to provide a role to custom button elements to ensure Name, Role, Value is conformant.

Role

On Android, you can manually set a role via the setRoleDescription method of AccessibilityNodeInfoCompat. It is usually better to use the setClassName method to inherit the role of an existing element. For example, set Button::class.java.name if an element should behave like a button.

ViewCompat.setAccessibilityDelegate(
    element,
    object : AccessibilityDelegateCompat() {
        override fun onInitializeAccessibilityNodeInfo(
            host: View,
            info: AccessibilityNodeInfoCompat
        ) {
            super.onInitializeAccessibilityNodeInfo(host, info)
            info.roleDescription = "Custom role"
            info.className = Button::class.java.name
        }
    }
)

Credit for above: AAPT-ORG Code Examples

That is all. Keep up the great work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant