Android Accessibility: Force the screen reader to read the role of a ViewGroup after its children content

144
July 12, 2019, at 9:40 PM

According to the Android accessibility tutorial by Google, to treat a set of elements as a single unit of information, we can group these elements in a focusable container and set the container's android:focusable attribute to true. By doing this we let the screen reader know that we want this content to be read by a single announcement.

So I have created the following layout XML:

<LinearLayout
  android:focusable="true"
  ...>
  <TextView 
    android:text="Text #1"
    ... />
  <TextView 
    android:text="Text #2"
    ... />
</LinearLayout>

By using AccessibilityNodeInfoCompat's setClassName method, I set the class name of my LinearLayout to android.widget.Button so that TalkBack could treat my view group as a button.

This is how my accessibility tree looks like after this:

Button:(0, 722 - 1080, 905):FAC:focusable:clickable
  TextView:(44, 761 - 970, 813):TEXT{Text #1}:A:supportsTextLocation
  TextView:(44, 813 - 970, 865):TEXT{Text #2}:A:supportsTextLocation

The problem is that when my group is focused by the screen reader, it announces it as "Button, Text #1 Text #2". But I want it to be "Text #1 Text #2, Button".

Is there a way to force TalkBack to read the children text first and only after the parent's role name?

Rent Charter Buses Company
READ ALSO
How can I develop facial recognition with Pepper [on hold]

How can I develop facial recognition with Pepper [on hold]

I want to try facial recognition (not detection) with robot Pepper (using Android SDK) and I am looking for the best way to help me doing that

126
How do I or is it possible to navigate from android main activity to xamarin form

How do I or is it possible to navigate from android main activity to xamarin form

I have been working with Xamarin for a few weeks now and I am stuckIn my Android MainActivity

138
How To render the directions when Linking Google maps App in react native?

How To render the directions when Linking Google maps App in react native?

I want to render the directions between tow point (current location, passed location)

112