/**
*
* 转载请标明出处:http://blog.csdn.net/u013598111/article/details/50198101
* @author:【JunTao_sun】
*
*
*/
用自己的理解 小翻译了API
<span style="font-size:18px;">/**
* This class encapsulates scrolling with the ability to overshoot the bounds
* of a scrolling operation. This class is a drop-in replacement for
* {@link android.widget.Scroller} in most cases.
*/
/**
* Creates an OverScroller.
* @param context上下文对象
* @param interpolator 设置插值器r. 如果为空, 默认的 (viscous ['vɪskəs]粘性的) 插值器将会被使用
* @param flywheel 如果为true 在fling 快速滚动模式下 会不断增加滚动速度
* @hide
*/
public OverScroller(Context context, Interpolator interpolator, boolean flywheel) {
mInterpolator = interpolator;
mFlywheel = flywheel;
mScrollerX = new SplineOverScroller(context);
mScrollerY = new SplineOverScroller(context);
}</span>
encapsulates[ɪn'kæpsjə'let] 封装的意思
这个类封装了 作用于超过边界 滑动的操作 大部分情况下用这个overscroller代替srocller这个类
Public Methods | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
void |
abortAnimation
()
停止动画
| ||||||||||||||||||||
boolean |
computeScrollOffset
()
如果返回true 则说明滚动还没 (not yet )结束
| ||||||||||||||||||||
void |
fling
(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY) | ||||||||||||||||||||
void |
fling
(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY, int overX, int overY) Start scrolling based on a fling gesture. The distance traveled will depend on the initial velocity of the fling.
基于快速滑动触发的滚动, 滚动的距离 由初始的fling速度决定
Parameters 参数
| ||||||||||||||||||||
final void |
forceFinished
(boolean finished)
Force the finished field to a particular value. 停止动画
| ||||||||||||||||||||
float |
getCurrVelocity
()
Returns the absolute value of the current velocity. 返回当前速度的绝对值
| ||||||||||||||||||||
final int |
getCurrX
()
Returns the current X offset in the scroll. 返回当前 X轴滚动的偏移
| ||||||||||||||||||||
final int |
getCurrY
()
Returns the current Y offset in the scroll.返回当前 Y轴滚动的偏移
| ||||||||||||||||||||
final int |
getFinalX
()
Returns where the scroll will end. 返回滚动结束的X位置
| ||||||||||||||||||||
final int |
getFinalY
()
Returns where the scroll will end.返回滚动结束Y位置
| ||||||||||||||||||||
final int |
getStartX
()
Returns the start X offset in the scroll.返回开始滚动的X轴位置
| ||||||||||||||||||||
final int |
getStartY
()
Returns the start Y offset in the scroll.返回开始滚动的Y轴位置
| ||||||||||||||||||||
final boolean |
isFinished
()
Returns whether the scroller has finished scrolling. 返回是否滚动结束
| ||||||||||||||||||||
boolean |
isOverScrolled
()
Returns whether the current Scroller is currently returning to a valid position.返回当前的位置是否有效 或者是否超出滚动边界
| ||||||||||||||||||||
void |
notifyHorizontalEdgeReached
(int startX, int finalX, int overX)
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(合适).
通知水平滚动是否到达边界,通常 这个信息来处理 知道什么时候已经开始滚动,比如在调用fling这个方法,然而很多情况下,这不能提前知道 ,这个方法将 开始X到结束X 转化成合适的值 作为当前的动作和动画
| ||||||||||||||||||||
void |
notifyVerticalEdgeReached
(int startY, int finalY, int overY)
Notify the scroller that we've reached a vertical boundary. 跟上个方法同理
| ||||||||||||||||||||
final void |
setFriction
(float friction)
The amount of friction applied to flings. 给fling motion的时候设置摩擦因子
| ||||||||||||||||||||
boolean |
springBack
(int startX, int startY, int minX, int maxX, int minY, int maxY)Parameters
Call this when you want to 'spring back' into a valid coordinate range.当你想回滚的时候 调用这个方法 回滚的范围在有效的坐标范围内
| ||||||||||||||||||||
void |
startScroll
(int startX, int startY, int dx, int dy)
Start scrolling by providing a starting point and the distance to travel.通过 2个点 计算滚动的值的变化
| ||||||||||||||||||||
void |
startScroll
(int startX, int startY, int dx, int dy, int duration) 通过开始点和结束点 还有距离 计算值的变化
Start scrolling by providing a starting point and the distance to travel.
|