Accessibility value - Android
Android has limited support to provide a dedicated accessibility value for assistive technologies. The AccessibilityNodeInfoCompat
object contains a couple of methods, such as the setChecked
method.
Unfortunately the desired value is often not available. If your desired value is not included, you can append it to the contentDescription
attribute.
ViewCompat.setAccessibilityDelegate(
element,
object : AccessibilityDelegateCompat() {
override fun onInitializeAccessibilityNodeInfo(
host: View,
info: AccessibilityNodeInfoCompat
) {
super.onInitializeAccessibilityNodeInfo(host, info)
info.isChecked = true
}
}
)
element.contentDescription = "Name (Value)"