diff options
| author | 2010-02-16 12:26:33 -0800 | |
|---|---|---|
| committer | 2010-02-16 12:26:33 -0800 | |
| commit | a2f91016840bf4f7274577d40f3610e38b77f2ad (patch) | |
| tree | 2129621f77a987e78eaea6030703bbeb6559f556 | |
| parent | 3d0ff09e35521a97ec1cfe14d57c6868e271fe9a (diff) | |
Fix for [Horizontal]ScrollView scroll range reporting
| -rw-r--r-- | core/java/android/widget/HorizontalScrollView.java | 9 | ||||
| -rw-r--r-- | core/java/android/widget/ScrollView.java | 9 |
2 files changed, 10 insertions, 8 deletions
diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java index c62724c75341..a7b819a57850 100644 --- a/core/java/android/widget/HorizontalScrollView.java +++ b/core/java/android/widget/HorizontalScrollView.java @@ -890,14 +890,15 @@ public class HorizontalScrollView extends FrameLayout { */ @Override protected int computeHorizontalScrollRange() { - int count = getChildCount(); + final int count = getChildCount(); + final int contentWidth = getWidth() - mPaddingLeft - mPaddingRight; if (count == 0) { - return getWidth(); + return contentWidth; } int scrollRange = getChildAt(0).getRight(); - int scrollX = mScrollX; - int overscrollRight = scrollRange - getWidth() - mPaddingLeft - mPaddingRight; + final int scrollX = mScrollX; + final int overscrollRight = Math.max(0, scrollRange - contentWidth); if (scrollX < 0) { scrollRange -= scrollX; } else if (scrollX > overscrollRight) { diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index 2ee7ad5517f9..52ed11d6d069 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -892,14 +892,15 @@ public class ScrollView extends FrameLayout { */ @Override protected int computeVerticalScrollRange() { - int count = getChildCount(); + final int count = getChildCount(); + final int contentHeight = getHeight() - mPaddingBottom - mPaddingTop; if (count == 0) { - return getHeight(); + return contentHeight; } int scrollRange = getChildAt(0).getBottom(); - int scrollY = mScrollY; - int overscrollBottom = scrollRange - getHeight() - mPaddingBottom - mPaddingTop; + final int scrollY = mScrollY; + final int overscrollBottom = Math.max(0, scrollRange - contentHeight); if (scrollY < 0) { scrollRange -= scrollY; } else if (scrollY > overscrollBottom) { |