Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't nextFocusDown work with TalkBack navigation?

I have four TextViews, and I'm trying to control the order that they get focus when a user navigates using TalkBack and touch gestures.

TextView android:text="foo" android:clickable="false" android:focusable="true" android:focusableInTouchMode="true" android:id="@+id/id_foo" android:nextFocusDown="@+id/id_baz"/>

TextView android:text="bar" android:clickable="false" android:focusable="true" android:focusableInTouchMode="true" android:id="@+id/id_bar" android:nextFocusDown="@+id/id_qux"/>

TextView android:text="baz" android:clickable="false" android:focusable="true" android:focusableInTouchMode="true" android:id="@id/id_baz" android:nextFocusDown="@id/id_bar"/>

TextView android:text="qux" android:clickable="false" android:focusable="true" android:focusableInTouchMode="true" android:id="@id/id_qux" android:nextFocusDown="@id/id_foo"/>

When a user turns on TalkBack, touches "foo", and then swipes down to navigate between the TextViews, I want the order to go foo->baz->bar->qux. But, the order I try to set up using nextFocusDown seems to have no effect, and instead focus order always just follows the positions of the TextViews on the screen. I've tried every possible combination of clickable, focusable, and focusableInTouchMode. I've tried calling setNextFocusDownId on the views in code. I've tried setting android:imeOptions="actionNext" on the TextViews. Nothing seems to work. What am I missing?

like image 252
Norioch Avatar asked Feb 02 '15 23:02

Norioch


2 Answers

Try to use View.setAccessibilityTraversalAfter(int) and View.setAccessibilityTraversalBefore(int) to configure TalkBack navigation. Please note that TalkBack has only two directions:

  • forward (swipe to the right or down)
  • back (swipe to the left or up).

Example:

findView(R.id.bar).setAccessibilityTraversalBefore(R.id.quix);
like image 157
IPhone Guy Avatar answered Dec 28 '22 01:12

IPhone Guy


NextFocusDown doesn't refer to TalkBack gestures. It refers to track-ball and keyboard arrow key navigation. TalkBack exploration gestures are limited to swiping down/right for next focus, and swiping up/left for previous focus. And of course, drag to explore.

like image 36
ChrisCM Avatar answered Dec 28 '22 01:12

ChrisCM