Code example for Scroller

0
 
    /** 
     * Sets up the scroller and touch/fling sensitivity parameters for the pager. 
     */ 
    private void init() { 
        mScroller = new Scroller(getContext());
 
        // Calculate the density-dependent snap velocity in pixels 
        DisplayMetrics displayMetrics = new DisplayMetrics();
        ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
                .getMetrics(displayMetrics);
        mDensityAdjustedSnapVelocity =
                (int) (displayMetrics.density * SNAP_VELOCITY_DIP_PER_SECOND);
 
        final ViewConfiguration configuration = ViewConfiguration.get(getContext());
        mTouchSlop = configuration.getScaledTouchSlop();
        mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    } 
 
    @Override 
    protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {