Android OverScroller - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android OverScroller class.

This code example shows how to use the following methods: computeScrollOffset, getCurrX, getCurrY
		} 
	}; 
	 
	@Override 
	public void computeScroll() { 
        if (mScroller.computeScrollOffset()) {
            // This is called at drawing time by ViewGroup.  We use 
            // this method to keep the fling animation going through 
            // to completion. 
            int oldX = getScrollX();
            int oldY = getScrollY();
            int x = mScroller.getCurrX();
            int y = mScroller.getCurrY();
 
            if (getChildCount() > 0) {
                View child = getChildAt(0);
                x = clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth());
                y = clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight());
                if (x != oldX || y != oldY) {
                    scrollTo(x, y);
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: computeScrollOffset, getCurrX, getCurrY
        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
    } 
	 
	@Override 
	public void computeScroll() { 
        if (mScroller.computeScrollOffset()) {
            // This is called at drawing time by ViewGroup.  We use 
            // this method to keep the fling animation going through 
            // to completion. 
            int oldX = getScrollX();
            int oldY = getScrollY();
            int x = mScroller.getCurrX();
            int y = mScroller.getCurrY();
 
            if (getChildCount() > 0) {
                View child = getChildAt(0);
                x = clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth());
                y = clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight());
                if (x != oldX || y != oldY) {
                    scrollTo(x, y);
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getCurrX, getFinalX, startScroll
                mOverflingEnabled ? mOverflingDistance : 0, 0);
    } 
 
    // Returns the distance that over the scroll limit. 
    public int startScroll(int distance, int min, int max) {
        int currPosition = mScroller.getCurrX();
        int finalPosition = mScroller.getFinalX();
        int newPosition = Utils.clamp(finalPosition + distance, min, max);
        if (newPosition != currPosition) {
            mScroller.startScroll(
                currPosition, 0,                    // startX, startY
                newPosition - currPosition, 0, 0);  // dx, dy, duration
        } 
        return finalPosition + distance - newPosition;
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getFinalX, getFinalY, getStartX, getStartY, isFinished
    } 
     
    // from OverScroller.java 
     
    static public boolean isScrollingInDirection(OverScroller scroller, float xvel, float yvel) {
        final int dx = scroller.getFinalX() - scroller.getStartX();
        final int dy = scroller.getFinalY() - scroller.getStartY();
        return !scroller.isFinished() && Math.signum(xvel) == Math.signum(dx) &&
                Math.signum(yvel) == Math.signum(dy);
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getCurrVelocity
     * @see android.view.ScaleGestureDetector#getCurrentSpanY() 
     */ 
    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    public static float getCurrVelocity(OverScroller overScroller) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            return overScroller.getCurrVelocity();
        } else { 
            return 0; 
        } 
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android OverScroller Questions & Answers:

See Code Examples for Android OverScroller Methods: