Android 初探OverScroller


/**

 *
 * 转载请标明出处:http://blog.csdn.net/u013598111/article/details/50198101

 *   @author:【JunTao_sun】
 *
 *
*/



用自己的理解 小翻译了API 

/**
* 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);
}


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 参数
startX Starting point of the scroll (X)  开始点的X坐标
startY Starting point of the scroll (Y) 开始点的Y坐标
velocityX

Initial velocity of the fling (X) measured in pixels per second.    

以每秒像素的速度计算 Fling X时候 初始的速度

velocityY

Initial velocity of the fling (Y) measured in pixels per second    

以每秒像素的速度计算 Fling Y时候 初始的速度

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. 设置最小值的X点   scroller 不滚动超过这个点  除非overX 大于0     如果允许滚动出范围 将用最小的Xvalue做为回滚的边界
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. 
 fling滚动超过有效值的范围  当这X大于0      水平 滚动越过两个方向都有可能
overY Overfling range. If > 0, vertical overfling in either direction will be possible.

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
startX Starting X coordinate  开始的X坐标
startY Starting Y coordinate 结束的Y坐标
minX Minimum valid X value 最小的有效X坐标
maxX Maximum valid X value最大的有效X坐标
minY Minimum valid Y value最小的有效Y坐标
maxY Minimum valid Y value最大的有效Y坐标

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.


你可能感兴趣的:(android基础)