diff options
| -rw-r--r-- | core/java/android/view/View.java | 68 | ||||
| -rw-r--r-- | core/res/res/values/attrs.xml | 12 |
2 files changed, 49 insertions, 31 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 398987f64844..c7303f4b9dbb 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -11287,26 +11287,36 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** - * Sets the id of a view before which this one is visited in accessibility traversal. - * A screen-reader must visit the content of this view before the content of the one - * it precedes. For example, if view B is set to be before view A, then a screen-reader - * will traverse the entire content of B before traversing the entire content of A, - * regardles of what traversal strategy it is using. + * Sets the id of a view that screen readers are requested to visit after this view. + * * <p> - * Views that do not have specified before/after relationships are traversed in order - * determined by the screen-reader. - * </p> + * + * For example, if view B should be visited before view A, with + * B.setAccessibilityTraversalBefore(A), this requests that screen readers visit and traverse + * view B before visiting view A. + * * <p> - * Setting that this view is before a view that is not important for accessibility - * or if this view is not important for accessibility will have no effect as the - * screen-reader is not aware of unimportant views. - * </p> + * <b>Note:</b> Views are visited in the order determined by the screen reader. Avoid + * explicitly manipulating focus order, as this may result in inconsistent user + * experiences between apps. Instead, use other semantics, such as restructuring the view + * hierarchy layout, to communicate order. + * + * <p> + * Setting this view to be after a view that is not important for accessibility, + * or if this view is not important for accessibility, means this method will have no effect if + * the service is not aware of unimportant views. + * + * <p> + * To avoid a risk of loops, set clear relationships between views. For example, if focus order + * should be B -> A, and B.setAccessibilityTraversalBefore(A), then also call + * A.setAccessibilityTraversalAfter(B). * * @param beforeId The id of a view this one precedes in accessibility traversal. * * @attr ref android.R.styleable#View_accessibilityTraversalBefore * * @see #setImportantForAccessibility(int) + * @see #setAccessibilityTraversalAfter(int) */ @RemotableViewMethod public void setAccessibilityTraversalBefore(@IdRes int beforeId) { @@ -11333,26 +11343,34 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** - * Sets the id of a view after which this one is visited in accessibility traversal. - * A screen-reader must visit the content of the other view before the content of this - * one. For example, if view B is set to be after view A, then a screen-reader - * will traverse the entire content of A before traversing the entire content of B, - * regardles of what traversal strategy it is using. + * Sets the id of a view that screen readers are requested to visit before this view. + * * <p> - * Views that do not have specified before/after relationships are traversed in order - * determined by the screen-reader. - * </p> + * For example, if view B should be visited after A, with B.setAccessibilityTraversalAfter(A), + * then this requests that screen readers visit and traverse view A before visiting view B. + * * <p> - * Setting that this view is after a view that is not important for accessibility - * or if this view is not important for accessibility will have no effect as the - * screen-reader is not aware of unimportant views. - * </p> + * <b>Note:</b> Views are visited in the order determined by the screen reader. Avoid + * explicitly manipulating focus order, as this may result in inconsistent user + * experiences between apps. Instead, use other semantics, such as restructuring the view + * hierarchy layout, to communicate order. * - * @param afterId The id of a view this one succedees in accessibility traversal. + * <p> + * Setting this view to be after a view that is not important for accessibility, + * or if this view is not important for accessibility, means this method will have no effect if + * the service is not aware of unimportant views. + * + * <p> + * To avoid a risk of loops, set clear relationships between views. For example, if focus order + * should be B -> A, and B.setAccessibilityTraversalBefore(A), then also call + * A.setAccessibilityTraversalAfter(B). + * + * @param afterId The id of a view this one succeeds in accessibility traversal. * * @attr ref android.R.styleable#View_accessibilityTraversalAfter * * @see #setImportantForAccessibility(int) + * @see #setAccessibilityTraversalBefore(int) */ @RemotableViewMethod public void setAccessibilityTraversalAfter(@IdRes int afterId) { diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 55122ce25ea1..d80cfa340dcb 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -3030,15 +3030,15 @@ representation this attribute can be used for providing such. --> <attr name="contentDescription" format="string" localization="suggested" /> - <!-- Sets the id of a view before which this one is visited in accessibility traversal. - A screen-reader must visit the content of this view before the content of the one - it precedes. + <!-- Sets the id of a view that screen readers are requested to visit after this view. + Requests that a screen-reader visits the content of this view before the content of the + one it precedes. This does nothing if either view is not important for accessibility. {@see android.view.View#setAccessibilityTraversalBefore(int)} --> <attr name="accessibilityTraversalBefore" format="integer" /> - <!-- Sets the id of a view after which this one is visited in accessibility traversal. - A screen-reader must visit the content of the other view before the content of - this one. + <!-- Sets the id of a view that screen readers are requested to visit before this view. + Requests that a screen-reader visits the content of the other view before the content + of this one. This does nothing if either view is not important for accessibility. {@see android.view.View#setAccessibilityTraversalAfter(int)} --> <attr name="accessibilityTraversalAfter" format="integer" /> |