magentaA11y icon indicating copy to clipboard operation
magentaA11y copied to clipboard

[Feedback] [Native Android] - Button

Open a11yjc opened this issue 2 years ago • 0 comments

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.

a11yjc avatar Apr 04 '22 16:04 a11yjc