,这里就不详细介绍了
android.view.VelocityTracker android.view.Scroller android.view。ViewConfiguration
- <李>
void init (Context 上下文),{ ,,,,,,,,,,,,,,,mScroller =, new 照片卷轴(getContext ()); ,,,,,,,,,,,,,,,setFocusable(真正的); ,,,,,,,,,,,,,,,setDescendantFocusability (FOCUS_AFTER_DESCENDANTS); ,,,,,,,,,,,,,,,setWillNotDraw(假); ,,,,,,,,,,,,,,,final ViewConfiguration configuration =, ViewConfiguration.get(上下文); ,,,,,,,,,,,,,,,mTouchSlop =, configuration.getScaledTouchSlop (); ,,,,,,,,,,,,,,,mMinimumVelocity =, configuration.getScaledMinimumFlingVelocity (); ,,,,,,,,,,,,,,,mMaximumVelocity =, configuration.getScaledMaximumFlingVelocity (); ,,,,,,,}李>
<强> Java代码强>
- <李>
public void 舞(int velocityY), { ,,,,,,,if (getChildCount(),祝辞,0),{ ,,,,,,,,,,,,,,,mScroller.fling (getScrollX (),, getScrollY (),, 0,, velocityY,, 0, 0, 0, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,maxScrollEdge); ,,,,,,,,,,,,,,,final boolean movingDown =, velocityY 祝辞,0; ,,,,,,,,,,,,,,,awakenScrollBars (mScroller.getDuration ()); ,,,,,,,,,,,,,,,invalidate (); ,,,,,,,} 李}>
<强> Java代码强>
- <李>
private void obtainVelocityTracker (MotionEvent 事件),{ ,,,,,,,if (mVelocityTracker ==, null), { ,,,,,,,,,,,,,,,mVelocityTracker =, VelocityTracker.obtain (); ,,,,,,,} ,,,,,,,mVelocityTracker.addMovement(事件); } private void  releaseVelocityTracker (), { ,,,,,,,if (mVelocityTracker !=, null), { ,,,,,,,,,,,,,,,mVelocityTracker.recycle (); ,,,,,,,,,,,,,,,mVelocityTracker =,空; ,,,,,,,} 李}>
<强> Java代码强>
- <李>
公共布尔> <李>
公共空computeScroll () {
,,,,如果(mScroller.computeScrollOffset ()) {
,,,,,,,,int scrollX=getScrollX ();
,,,,,,,,int scrollY=getScrollY ();
,,,,,,,,int oldX=scrollX;
,,,,,,,,int老人=scrollY;
,,,,,,,,int x=mScroller.getCurrX ();
,,,,,,,,int y=mScroller.getCurrY ();
,,,,,,,,scrollX=x;
,,,,,,,,scrollY=y;
,,null