Code example for ScrollView

Methods: getScrollY, post

0
        int time = mMinAnimationDuration;
        if (velocity != 0)
            time = Math.max(mMinAnimationDuration, (int) ((float) delta / Math.abs(velocity)));
 
        mScroller.startScroll(0, getCurrentScrollY(), 0, delta, time);
        mScrollView.post(mScrollRunnable); // Start animation.
    } 
 
    /** 
     * Will completely clear state and stop any scrolling 
     */ 
    void resetPager() 
    { 
        if (!mScroller.isFinished())
        { 
            mScroller.abortAnimation();
            mScrollView.removeCallbacks(mScrollRunnable);
        } 
        mIsScrolling = false;
//        resetVelocityTracker(); 
    } 
 
    void resetVelocityTracker() 
    { 
        mInitialY = mLastY = -1;
        if (mVelocityTracker != null)
        { 
            mVelocityTracker.recycle();
            mVelocityTracker = null;
        } 
    } 
 
    final void calculateNextPage() 
    { 
        //                        if (velocityY < -mMinVelocity) 
//                            snapToPage(mCurrentPage + 1, velocityY); 
//                        else if (velocityY > mMinVelocity) 
//                            snapToPage(mCurrentPage - 1, velocityY); 
    } 
 
    /** 
     * Works out how many pages there on based off the content height 
     * 
     * @return 
     */ 
    public int getPageCount() 
    { 
        return mContentView.getChildCount();
//        return Math.round((float) mContentView.getHeight() / (float) mScrollView.getHeight()); 
    } 
 
    final int getCurrentScrollY() 
    { 
        return mScrollView.getScrollY();
    } 
 
 
    /** 
     * Works out the current page you are looking at. Or which is at least overlaps the middle of the scroll view