1

How can I set the talkback/accessibility order in a constraint layout?

I have a layout with a couple of text/imageviews. By clicking on the layout talkback reads them in order. How can I change the order it reads them?

e.g.: I want the order to be 3-1-2 instead of 1-2-3 (numbers are the textviews). I tried traversalAfter/Before but that doesn't work :/

EricSchaefer
  • 25,272
  • 21
  • 67
  • 103
SkurSkurrrr
  • 99
  • 2
  • 9

1 Answers1

1

You can change the traversal order of the talkback by doing something like this

<TextView
    android:id="@+id/textView1"
    android:layout_width="30dp"
    android:accessibilityTraversalAfter="@id/textView3"
    android:layout_height="30dp"
    android:src="@drawable/ic_launcher" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="30dp"
    android:accessibilityTraversalAfter="@id/textView2"
    android:layout_height="30dp"
    android:src="@drawable/ic_launcher" />

<Textview
    android:id="@+id/textView3"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:src="@drawable/ic_launcher" />

However this will only work for minSdkLevel>=22

Narendra_Nath
  • 4,578
  • 3
  • 13
  • 31
  • as i said, i already tried this but it doesnt affect the order at all :/ – SkurSkurrrr May 10 '21 at 08:07
  • did you set the minSdkVersion>=22 – Narendra_Nath May 10 '21 at 08:09
  • Please include your code and here's a helpful answer. https://stackoverflow.com/questions/26729909/modify-accessibility-focus-order – Narendra_Nath May 10 '21 at 08:11
  • i wish i could but it is work related. it is a Constraint Layout with Text Views and another Layout inside of that with one view. It starts by reading the views from the root layout and then the view from the nested layout. But i need it the other way around. – SkurSkurrrr May 10 '21 at 08:15
  • is it possible to wrap those in the same root hierarchy. Maybe that is what is stopping the order to kick in.. try introduce or remove layouts such that they exist equally in the root hierchy order – Narendra_Nath May 10 '21 at 08:49
  • the weird thing is, even the order of those views in the same layout wont change their order when i try that – SkurSkurrrr May 10 '21 at 09:03
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/232179/discussion-between-narendra-nath-and-skurskurrrr). – Narendra_Nath May 10 '21 at 17:32