Code example for Scroller

Methods: getCurrY, getFinalX, getFinalY, startScroll

0
			} 
		} 
	} 
 
	public void smoothScrollBy(int dx, int dy) {
		mScroller.startScroll(mScroller.getFinalX(), mScroller.getFinalY(), dx,
				dy);
		invalidate();
	} 
 
	public void smoothScrollTo(int fx, int fy) {
		int dx = fx - mScroller.getFinalX();
		int dy = fy - mScroller.getFinalY();
		smoothScrollBy(dx, dy);
	} 
 
	@Override 
	public boolean onTouchEvent(MotionEvent event) {
		final int action = event.getAction();
		final float x = event.getX();
		final float y = event.getY();
 
		switch (action) {
		case MotionEvent.ACTION_DOWN:
			if (!mScroller.isFinished()) {
				mScroller.abortAnimation();
			} 
			mLastMotionX = x;
			mLastMotionY = y;
			break; 
		case MotionEvent.ACTION_MOVE:
			int dy = (int) (mLastMotionY - y);
			if(mScroller.getCurrY()+dy>0){
				smoothScrollBy(0, 0); 
			}else if(mScroller.getCurrY()+dy<-mBottomView.getChildAt(0).getHeight()){
				smoothScrollTo(0, -mBottomView.getChildAt(0).getHeight());
			}else{ 
				smoothScrollBy(0, dy);
			} 
			mLastMotionX = x;