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?
Try to use View.setAccessibilityTraversalAfter(int) and View.setAccessibilityTraversalBefore(int) to configure TalkBack navigation. Please note that TalkBack has only two directions:
Example:
findView(R.id.bar).setAccessibilityTraversalBefore(R.id.quix);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With