Code example for OverScroller

Methods: fling

0
            int height = getHeight() - getPaddingBottom() - getPaddingTop();
            int width = getWidth() - getPaddingLeft() - getPaddingRight();
            int bottom = getChildAt(0).getHeight();
            int right = getChildAt(0).getWidth();
 
            mScroller.fling(getScrollX(), getScrollY(), velocityX, velocityY,
            		0, Math.max(0, right - width),
            		0, Math.max(0, bottom - height));
     
            invalidate();
        } 
    } 
	 
	/* 
	 * Utility method to assist in doing bounds checking 
	 */ 
    private int clamp(int n, int my, int child) {
        if (my >= child || n < 0) {
            /* my >= child is this case: 
             *                    |--------------- me ---------------| 
             *     |------ child ------|