java.lang.Object | |
↳ | android.widget.OverScroller |
This class encapsulates scrolling with the ability to overshoot the bounds
of a scrolling operation. This class is a drop-in replacement for
Scroller
in most cases.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates an OverScroller with a viscous fluid scroll interpolator and flywheel.
| |||||||||||
Creates an OverScroller with flywheel enabled.
| |||||||||||
Creates an OverScroller with flywheel enabled.
| |||||||||||
Creates an OverScroller.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Stops the animation.
| |||||||||||
Call this when you want to know the new location.
| |||||||||||
Start scrolling based on a fling gesture.
| |||||||||||
Force the finished field to a particular value.
| |||||||||||
Returns the absolute value of the current velocity.
| |||||||||||
Returns the current X offset in the scroll.
| |||||||||||
Returns the current Y offset in the scroll.
| |||||||||||
Returns where the scroll will end.
| |||||||||||
Returns where the scroll will end.
| |||||||||||
Returns the start X offset in the scroll.
| |||||||||||
Returns the start Y offset in the scroll.
| |||||||||||
Returns whether the scroller has finished scrolling.
| |||||||||||
Returns whether the current Scroller is currently returning to a valid position.
| |||||||||||
Notify the scroller that we've reached a horizontal boundary.
| |||||||||||
Notify the scroller that we've reached a vertical boundary.
| |||||||||||
The amount of friction applied to flings.
| |||||||||||
Call this when you want to 'spring back' into a valid coordinate range.
| |||||||||||
Start scrolling by providing a starting point and the distance to travel.
| |||||||||||
Start scrolling by providing a starting point and the distance to travel.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Creates an OverScroller with a viscous fluid scroll interpolator and flywheel.
Creates an OverScroller with flywheel enabled.
context | The context of this application. |
---|---|
interpolator | The scroll interpolator. If null, a default (viscous) interpolator will be used. |
Creates an OverScroller with flywheel enabled.
context | The context of this application. |
---|---|
interpolator | The scroll interpolator. If null, a default (viscous) interpolator will be used. |
bounceCoefficientX | A value between 0 and 1 that will determine the proportion of the velocity which is preserved in the bounce when the horizontal edge is reached. A null value means no bounce. This behavior is no longer supported and this coefficient has no effect. |
bounceCoefficientY | Same as bounceCoefficientX but for the vertical direction. This behavior is no longer supported and this coefficient has no effect. !deprecated Use {!link #OverScroller(Context, Interpolator, boolean)} instead. |
Creates an OverScroller.
context | The context of this application. |
---|---|
interpolator | The scroll interpolator. If null, a default (viscous) interpolator will be used. |
bounceCoefficientX | A value between 0 and 1 that will determine the proportion of the velocity which is preserved in the bounce when the horizontal edge is reached. A null value means no bounce. This behavior is no longer supported and this coefficient has no effect. |
bounceCoefficientY | Same as bounceCoefficientX but for the vertical direction. This behavior is no longer supported and this coefficient has no effect. |
flywheel | If true, successive fling motions will keep on increasing scroll speed. !deprecated Use {!link OverScroller(Context, Interpolator, boolean)} instead. |
Stops the animation. Contrary to forceFinished(boolean)
,
aborting the animating causes the scroller to move to the final x and y
positions.
Call this when you want to know the new location. If it returns true, the animation is not yet finished.
Start scrolling based on a fling gesture. The distance traveled will depend on the initial velocity of the fling.
startX | Starting point of the scroll (X) |
---|---|
startY | Starting point of the scroll (Y) |
velocityX | Initial velocity of the fling (X) measured in pixels per second. |
velocityY | Initial velocity of the fling (Y) measured in pixels per second |
minX | Minimum X value. The scroller will not scroll past this point unless overX > 0. If overfling is allowed, it will use minX as a springback boundary. |
maxX | Maximum X value. The scroller will not scroll past this point unless overX > 0. If overfling is allowed, it will use maxX as a springback boundary. |
minY | Minimum Y value. The scroller will not scroll past this point unless overY > 0. If overfling is allowed, it will use minY as a springback boundary. |
maxY | Maximum Y value. The scroller will not scroll past this point unless overY > 0. If overfling is allowed, it will use maxY as a springback boundary. |
overX | Overfling range. If > 0, horizontal overfling in either direction will be possible. |
overY | Overfling range. If > 0, vertical overfling in either direction will be possible. |
Force the finished field to a particular value. Contrary to
abortAnimation()
, forcing the animation to finished
does NOT cause the scroller to move to the final x and y
position.
finished | The new finished value. |
---|
Returns the absolute value of the current velocity.
Returns the current X offset in the scroll.
Returns the current Y offset in the scroll.
Returns where the scroll will end. Valid only for "fling" scrolls.
Returns where the scroll will end. Valid only for "fling" scrolls.
Returns the start X offset in the scroll.
Returns the start Y offset in the scroll.
Returns whether the scroller has finished scrolling.
Returns whether the current Scroller is currently returning to a valid position.
Valid bounds were provided by the
fling(int, int, int, int, int, int, int, int, int, int)
method.
One should check this value before calling
startScroll(int, int, int, int)
as the interpolation currently in progress
to restore a valid position will then be stopped. The caller has to take into account
the fact that the started scroll will start from an overscrolled position.
Notify the scroller that we've reached a horizontal boundary. Normally the information to handle this will already be known when the animation is started, such as in a call to one of the fling functions. However there are cases where this cannot be known in advance. This function will transition the current motion and animate from startX to finalX as appropriate.
startX | Starting/current X position |
---|---|
finalX | Desired final X position |
overX | Magnitude of overscroll allowed. This should be the maximum desired distance from finalX. Absolute value - must be positive. |
Notify the scroller that we've reached a vertical boundary. Normally the information to handle this will already be known when the animation is started, such as in a call to one of the fling functions. However there are cases where this cannot be known in advance. This function will animate a parabolic motion from startY to finalY.
startY | Starting/current Y position |
---|---|
finalY | Desired final Y position |
overY | Magnitude of overscroll allowed. This should be the maximum desired distance from finalY. Absolute value - must be positive. |
The amount of friction applied to flings. The default value
is getScrollFriction()
.
friction | A scalar dimension-less value representing the coefficient of friction. |
---|
Call this when you want to 'spring back' into a valid coordinate range.
startX | Starting X coordinate |
---|---|
startY | Starting Y coordinate |
minX | Minimum valid X value |
maxX | Maximum valid X value |
minY | Minimum valid Y value |
maxY | Minimum valid Y value |
Start scrolling by providing a starting point and the distance to travel. The scroll will use the default value of 250 milliseconds for the duration.
startX | Starting horizontal scroll offset in pixels. Positive numbers will scroll the content to the left. |
---|---|
startY | Starting vertical scroll offset in pixels. Positive numbers will scroll the content up. |
dx | Horizontal distance to travel. Positive numbers will scroll the content to the left. |
dy | Vertical distance to travel. Positive numbers will scroll the content up. |
Start scrolling by providing a starting point and the distance to travel.
startX | Starting horizontal scroll offset in pixels. Positive numbers will scroll the content to the left. |
---|---|
startY | Starting vertical scroll offset in pixels. Positive numbers will scroll the content up. |
dx | Horizontal distance to travel. Positive numbers will scroll the content to the left. |
dy | Vertical distance to travel. Positive numbers will scroll the content up. |
duration | Duration of the scroll in milliseconds. |