AutoScrollHelper
AutoScrollHelper is a utility class for adding automatic edge-triggered scrolling to Views.
Note: Implementing classes are responsible for overriding the scrollTargetBy, canTargetScrollHorizontally, and canTargetScrollVertically methods. See ListViewAutoScrollHelper for a android.widget.ListView -specific implementation.
Activation
Automatic scrolling starts when the user touches within an activation area. By default, activation areas are defined as the top, left, right, and bottom 20% of the host view's total area. Touching within the top activation area scrolls up, left scrolls to the left, and so on.As the user touches closer to the extreme edge of the activation area, scrolling accelerates up to a maximum velocity. When using the default edge type, EDGE_TYPE_INSIDE_EXTEND, moving outside of the view bounds will scroll at the maximum velocity.
The following activation properties may be configured:
- Delay after entering activation area before auto-scrolling begins, see setActivationDelay. Default value is getTapTimeout to avoid conflicting with taps.
- Location of activation areas, see setEdgeType. Default value is EDGE_TYPE_INSIDE_EXTEND.
- Size of activation areas relative to view size, see setRelativeEdges. Default value is 20% for both vertical and horizontal edges.
- Maximum size used to constrain relative size, see setMaximumEdges. Default value is NO_MAX.
Scrolling
When automatic scrolling is active, the helper will repeatedly call scrollTargetBy to apply new scrolling offsets.The following scrolling properties may be configured:
- Acceleration ramp-up duration, see setRampUpDuration. Default value is 500 milliseconds.
- Acceleration ramp-down duration, see setRampDownDuration. Default value is 500 milliseconds.
- Target velocity relative to view size, see setRelativeVelocity. Default value is 100% per second for both vertical and horizontal.
- Minimum velocity used to constrain relative velocity, see setMinimumVelocity. When set, scrolling will accelerate to the larger of either this value or the relative target value. Default value is approximately 5 centimeters or 315 dips per second.
- Maximum velocity used to constrain relative velocity, see setMaximumVelocity. Default value is approximately 25 centimeters or 1575 dips per second.
Inheritors
Properties
Link copied to clipboard
Edge type that specifies an activation area starting at the view bounds and extending inward.
Link copied to clipboard
Edge type that specifies an activation area starting at the view bounds and extending inward.
Link copied to clipboard
Edge type that specifies an activation area starting at the view bounds and extending outward.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Constant passed to setRelativeEdges or setRelativeVelocity.
Functions
Link copied to clipboard
Override this method to return whether the target view can be scrolled horizontally in a certain direction.
Link copied to clipboard
Override this method to return whether the target view can be scrolled vertically in a certain direction.
Link copied to clipboard
Indicates whether the scroll helper handles touch events exclusively during scrolling.
Link copied to clipboard
Handles touch events by activating automatic scrolling, adjusting scroll velocity, or stopping.
Link copied to clipboard
Override this method to scroll the target view by the specified number of pixels.
Link copied to clipboard
Sets the delay after entering an activation edge before activation of auto-scrolling.
Link copied to clipboard
Sets the activation edge type, one of:
- EDGE_TYPE_INSIDE for edges that respond to touches inside the bounds of the host view. If touch moves outside the bounds, scrolling will stop.
- EDGE_TYPE_INSIDE_EXTEND for inside edges that continued to scroll when touch moves outside the bounds of the host view.
- EDGE_TYPE_OUTSIDE for edges that only respond to touches that move outside the bounds of the host view.
Link copied to clipboard
Sets whether the scroll helper is enabled and should respond to touch events.
Link copied to clipboard
Enables or disables exclusive handling of touch events during scrolling.
Link copied to clipboard
Sets the absolute maximum edge size.
Link copied to clipboard
Sets the absolute maximum scrolling velocity.
Link copied to clipboard
Sets the absolute minimum scrolling velocity.
Link copied to clipboard
Sets the amount of time after de-activation of auto-scrolling that is takes to slow to a stop.
Link copied to clipboard
Sets the amount of time after activation of auto-scrolling that is takes to reach target velocity for the current touch position.
Link copied to clipboard
Sets the activation edge size relative to the host view's dimensions.
Link copied to clipboard
Sets the target scrolling velocity relative to the host view's dimensions.