8

Google's official docs say that I should be able to use nxtFocusDown/nextFocusRight to specify this but it is having no effect. I have set it through xml and code but the scroll ordering still selects the control last.

Mr_E
  • 679
  • 6
  • 15
  • 1
    Post some actual code dude. – Ankur Aggarwal Oct 26 '15 at 18:19
  • 'animatedHeader.setNextFocusRightId(R.id.fav_circle); animatedHeader.setNextFocusDownId(R.id.fav_circle); animatedHeader.setNextFocusForwardId(R.id.fav_circle); animatedHeader.setNextFocusLeftId(R.id.fav_circle); animatedHeader.setNextFocusUpId(R.id.fav_circle);' after I'm on animated header control, it skips fav_circle, scrolls all the other controls and then does fav_circle last – Mr_E Oct 26 '15 at 18:26
  • 1
    Input focus order doesn't affect accessibility focus traversal order. You would need to use accessibilityTraversalBefore/After. See the top solution here: http://stackoverflow.com/questions/26729909/modify-accessibility-focus-order – alanv Oct 26 '15 at 18:40
  • That's not what Google docs say: http://developer.android.com/guide/topics/ui/accessibility/apps.html#focus-order. TraversalBefore/After does not work on API 4.4. – Mr_E Oct 26 '15 at 18:42
  • 1
    It is also linked to here: http://android-developers.blogspot.ca/2012/04/accessibility-are-you-serving-all-your.html "In a few cases, you may need to make UI components focusable or change the focus order to be more logical." – Mr_E Oct 26 '15 at 20:09
  • 1
    When you say "scroll ordering" do you mean via accessibility traversal (e.g. swipe gesture) or keyboard (e.g. input focus) traversal? – alanv Oct 27 '15 at 16:47
  • 1
    Accessibility swipe gesture. – Mr_E Oct 27 '15 at 17:48
  • The "Enabling Focus Navigation" section of the page you linked refers only to input (e.g. keyboard) focus. The swipe gestures moves accessibility focus, which is a separate concept that was introduced in API 16. There is no way to control accessibility focus traversal order prior to API 22. – alanv Oct 27 '15 at 20:16
  • 2
    So if I want to support older devices I am forced to accepting the fact that it will read my UI out of order? Nothing can be done here? – Mr_E Nov 02 '15 at 16:15
  • @Mr_E: Yes. Early versions of talkback always announced in the top-down order that items appeared on screen, and there was no way to force it to do anything else. – Mooing Duck Jul 21 '17 at 17:54
  • 1
    @MooingDuck. Doesn't seem to be the case anymore. It seems there is a compat class for it: [AccessibilityNodeInfoCompat](https://developer.android.com/reference/android/support/v4/view/accessibility/AccessibilityNodeInfoCompat.html). It contains methods `setTraversalBefore` and `setTraversalAfter` which appear to have been added in support library 24.1.0. – user3829751 Nov 20 '17 at 21:09
  • @user3829751 I tried to use AccessibilityNodeInfoCompat with ViewCompat.setAccessibilityDelegate(myFirstView, new AccessibilityDelegateCompat() { ... }); the AccessibilityDelegateCompat overrides the method onInitializeAccessibilityNodeInfo where I set the traversal order for myFirstView using AccessibilityNodeInfoCompat; but it doesn't work for API < 22 – DSoldo Nov 22 '17 at 09:23
  • 1
    Bummer. Thought it was worth a shot. I guess we either need to design our UI hierarchy to match Accessibility hierarchy, or place a bunch of dummy views everywhere for accessibility users. – user3829751 Nov 22 '17 at 19:05

0 Answers0