Code example for Scroller

Methods: abortAnimation, computeScrollOffset, getCurrX, getCurrY, isFinished, startScroll

0
 
	public void flingBy(int x) {
		int startX = 0;
		int startY = 0;
		int dx = 0;
		if (!mScroller.isFinished() && mScroller.computeScrollOffset()) {
			// Use newest position 
			startX = mScroller.getCurrX();
			startY = mScroller.getCurrY();
			dx = x + getScrollX() - startX;
			mScroller.abortAnimation();
		} else { 
			startX = getScrollX();
			startY = getScrollY();
			dx = x;
		} 
 
		// Never scroll outside the bound 
		int endX = startX + dx;
		if (endX < mRightClamp) {
			dx = mRightClamp - startX;
		} else if (endX > 0) {
			dx = -startX;
		} 
 
		if (dx != 0) {
			mScroller.startScroll(startX, startY, dx, 0, 500 /* MS */);
			invalidate();
		} 
	} 
 
	public void setOnSlidingListener(OnSlidingListener listener) {