Language

AccessibilityNodeInfo.AccessibilityAction.ActionScrollBackward Property

Definition

Action to scroll the node content backward.

[Android.Runtime.Register("ACTION_SCROLL_BACKWARD")]
public static Android.Views.Accessibility.AccessibilityNodeInfo.AccessibilityAction ActionScrollBackward { get; }
[<Android.Runtime.Register("ACTION_SCROLL_BACKWARD")>]
static member ActionScrollBackward : Android.Views.Accessibility.AccessibilityNodeInfo.AccessibilityAction

Property Value

Attributes

Remarks

Action to scroll the node content backward.

The UI element that implements this should send a AccessibilityEvent.TYPE_VIEW_SCROLLED event. Depending on the orientation, this element should also add the relevant directional scroll actions of ACTION_SCROLL_LEFT, ACTION_SCROLL_RIGHT, ACTION_SCROLL_UP, and ACTION_SCROLL_DOWN. If the scrolling brings the next or previous element into view as the center element, such as in a ViewPager2, use ACTION_PAGE_DOWN and the other page actions instead of the directional actions.

onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
     super.onInitializeAccessibilityNodeInfo(info);
     if (canScrollBackward) {
         info.addAction(ACTION_SCROLL_BACKWARD);
         if (leftToRight) {
             info.addAction(ACTION_SCROLL_LEFT);
         } else {
             info.addAction(ACTION_SCROLL_RIGHT);
         }
     }
}
performAccessibilityAction(int action, Bundle bundle) {
     if (action == ACTION_SCROLL_BACKWARD) {
         scrollBackward();
     } else if (action == ACTION_SCROLL_LEFT) {
         if (!isRTL()){
             scrollBackward();
         }
     } else if (action == ACTION_SCROLL_RIGHT) {
         if (isRTL()){
             scrollBackward();
         }
     }
}
scrollBackward() {
    ...
    if (mAccessibilityManager.isEnabled()) {
        event = new AccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SCROLLED);
        event.setScrollDeltaX(dx);
        event.setScrollDeltaY(dy);
        event.setMaxScrollX(maxDx);
        event.setMaxScrollY(maxDY);
        sendAccessibilityEventUnchecked(event);
   }
}

Android reference for android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to