I have the latest version of Talkback and its announcing "My Top level Text Heading". Android native behaviour is adding "Heading" for my top level elements. I could not find a way to switch ON/OFF heading announcement. Is there an API to control its behaviour. In the previous version of Talkback versions it was not announcing "Heading" by itself.
Android accessibility identify heading
Asked Answered
What kind of control are you using to get it to read this? I have the opposite problem, I WANT it to read heading and have been having to put it in manually on the content description. –
Anlace
@Anlace Were you able to solve your issue? –
Dareen
You can enable or disable the "heading" accessibility property of any View
on API 19+:
ViewCompat.setAccessibilityDelegate(headingView, new AccessibilityDelegateCompat() {
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfo(host, info);
info.setHeading(true); // false to mark a view as not a heading
}
});
If you have minSdk 28, you can simply set this directly in your XML:
android:accessibilityHeading="false"
in which API this method added?
AccessibilityNodeInfoCompat#setHeading(boolean)
–
Vermillion Hi @Adam S , this does not appear to work for me. The textview is not announcing that it is a heading when you do
setHeading(true)
. –
Chenay Yup, it's added in 28 developer.android.com/reference/android/view/accessibility/… –
Sohn
Here is a simpler method:
ViewCompat.setAccessibilityHeading(headingView, false);
It's for 19 and lower. –
Sohn
@KornilovRuslan The doc says that this is a no-op on API < 19 –
Decagram
If you're only supporting API level 23 and above, you can simply do the following.
textView.setAccessibilityDelegate(new View.AccessibilityDelegate() {
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(host, info);
//blanked to prevent talkback from announcing class/type
info.setClassName("");
}
});
I solved this by passing heading as false in
AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain method.
// set the heading attribute to false so that heading is not announced in label
info.setCollectionItemInfo(
AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(glp.getSpanIndex(),
glp.getSpanSize(), spanGroupIndex, 1, false, false));
public static CollectionItemInfoCompat obtain(int rowIndex,
int rowSpan, int columnIndex, int columnSpan,
boolean heading, boolean selected)
how do you get glp, Or what's glp? –
Siloa
© 2022 - 2024 — McMap. All rights reserved.