ScrollFeedbackProviderCompat
class ScrollFeedbackProviderCompat
Compat to access ScrollFeedbackProvider across different build versions.
Summary
Public functions |
|
|---|---|
java-static ScrollFeedbackProviderCompat |
createProvider(view: View)Creates an instance of |
Unit |
onScrollLimit(inputDeviceId: Int, source: Int, axis: Int, isStart: Boolean)Call this when the view has reached the scroll limit. |
Unit |
onScrollProgress(Call this when the view has scrolled. |
Unit |
onSnapToItem(inputDeviceId: Int, source: Int, axis: Int)Call this when the view has snapped to an item. |
Public functions
createProvider
java-static fun createProvider(view: View): ScrollFeedbackProviderCompat
Creates an instance of ScrollFeedbackProviderCompat.
onScrollLimit
fun onScrollLimit(inputDeviceId: Int, source: Int, axis: Int, isStart: Boolean): Unit
Call this when the view has reached the scroll limit.
Note that a feedback may not be provided on every call to this method. This interface, for instance, may provide feedback on every `N`th scroll limit event. For the interface to properly provide feedback when needed, call this method for each scroll limit event that you want to be accounted to scroll limit feedback.
| Parameters | |
|---|---|
inputDeviceId: Int |
the ID of the |
source: Int |
the input source of the motion that caused scrolling to hit the limit. |
axis: Int |
the axis of |
isStart: Boolean |
|
onScrollProgress
fun onScrollProgress(
inputDeviceId: Int,
source: Int,
axis: Int,
deltaInPixels: Int
): Unit
Call this when the view has scrolled.
Different axes have different ways to map their raw axis values to pixels for scrolling. When calling this method, use the scroll values in pixels by which the view was scrolled; do not use the raw axis values. That is, use whatever value is passed to one of View's scrolling methods (example: scrollBy). For example, for vertical scrolling on AXIS_SCROLL, convert the raw axis value to the equivalent pixels by using getScaledVerticalScrollFactor, and use that value for this method call.
Note that a feedback may not be provided on every call to this method. This interface, for instance, may provide feedback for every `x` pixels scrolled. For the interface to properly track scroll progress and provide feedback when needed, call this method for each scroll event that you want to be accounted to scroll feedback.
| Parameters | |
|---|---|
inputDeviceId: Int |
the ID of the |
source: Int |
the input source of the motion that caused scroll progress. |
axis: Int |
the axis of |
deltaInPixels: Int |
the amount of scroll progress, in pixels. |
onSnapToItem
fun onSnapToItem(inputDeviceId: Int, source: Int, axis: Int): Unit
Call this when the view has snapped to an item.
| Parameters | |
|---|---|
inputDeviceId: Int |
the ID of the |
source: Int |
the input source of the motion causing the snap. |
axis: Int |
the axis of |