AutoScrollHelper
abstract class AutoScrollHelper : OnTouchListener
kotlin.Any | |
↳ | androidx.core.widget.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
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 isViewConfiguration#getTapTimeout()
to avoid conflicting with taps. - Location of activation areas, see
setEdgeType
. Default value isEDGE_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 isNO_MAX
.
Scrolling
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.
Summary
Constants | |
---|---|
static Int |
Edge type that specifies an activation area starting at the view bounds and extending inward. |
static Int |
Edge type that specifies an activation area starting at the view bounds and extending inward. |
static Int |
Edge type that specifies an activation area starting at the view bounds and extending outward. |
static Float |
Constant passed to |
static Float |
Constant passed to |
static Float |
Constant passed to |
Public constructors | |
---|---|
Creates a new helper for scrolling the specified target view. |
Public methods | |
---|---|
abstract Boolean |
canTargetScrollHorizontally(direction: Int) Override this method to return whether the target view can be scrolled horizontally in a certain direction. |
abstract Boolean |
canTargetScrollVertically(direction: Int) Override this method to return whether the target view can be scrolled vertically in a certain direction. |
open Boolean | |
open Boolean |
Indicates whether the scroll helper handles touch events exclusively during scrolling. |
open Boolean |
onTouch(v: View!, event: MotionEvent!) Handles touch events by activating automatic scrolling, adjusting scroll velocity, or stopping. |
abstract Unit |
scrollTargetBy(deltaX: Int, deltaY: Int) Override this method to scroll the target view by the specified number of pixels. |
open AutoScrollHelper |
setActivationDelay(delayMillis: Int) Sets the delay after entering an activation edge before activation of auto-scrolling. |
open AutoScrollHelper |
setEdgeType(type: Int) Sets the activation edge type, one of:
|
open AutoScrollHelper! |
setEnabled(enabled: Boolean) Sets whether the scroll helper is enabled and should respond to touch events. |
open AutoScrollHelper! |
setExclusive(exclusive: Boolean) Enables or disables exclusive handling of touch events during scrolling. |
open AutoScrollHelper |
setMaximumEdges(horizontalMax: Float, verticalMax: Float) Sets the absolute maximum edge size. |
open AutoScrollHelper |
setMaximumVelocity(horizontalMax: Float, verticalMax: Float) Sets the absolute ma |