}
long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll;
if (duration > ANIMATED_SCROLL_GAP) {
- int width = getWidth() - mPaddingRight - mPaddingLeft;
- int right = getChildAt(0).getWidth();
- mScroller.startScroll(mScrollX, mScrollY, dx, dy,
- 0, Math.max(0, right - width), 0, 0);
+ final int width = getWidth() - mPaddingRight - mPaddingLeft;
+ final int right = getChildAt(0).getWidth();
+ final int maxX = Math.max(0, right - width);
+ final int scrollX = mScrollX;
+ dx = Math.max(0, Math.min(scrollX + dx, maxX)) - scrollX;
+
+ mScroller.startScroll(scrollX, mScrollY, dx, 0);
awakenScrollBars(mScroller.getDuration());
invalidate();
} else {
}
long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll;
if (duration > ANIMATED_SCROLL_GAP) {
- int height = getHeight() - mPaddingBottom - mPaddingTop;
- int bottom = getChildAt(0).getHeight();
- mScroller.startScroll(mScrollX, mScrollY, dx, dy,
- 0, 0, 0, Math.max(0, bottom - height));
+ final int height = getHeight() - mPaddingBottom - mPaddingTop;
+ final int bottom = getChildAt(0).getHeight();
+ final int maxY = Math.max(0, bottom - height);
+ final int scrollY = mScrollY;
+ dy = Math.max(0, Math.min(scrollY + dy, maxY)) - scrollY;
+
+ mScroller.startScroll(mScrollX, scrollY, 0, dy);
awakenScrollBars(mScroller.getDuration());
invalidate();
} else {