summaryrefslogtreecommitdiff
path: root/core/java/android/widget/ScrollView.java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-01-28 13:52:24 -0800
committerAdam Powell <adamp@google.com>2010-01-28 13:52:24 -0800
commit3fc3737ceb0f5c3b086472fb2cf7ebfb089e1bc8 (patch)
tree12b4696577b449505552a61bf5f8b16f5023e166 /core/java/android/widget/ScrollView.java
parentf1a0f55f7145bc3c769752395d29b282f1f133f2 (diff)
ScrollView and HorizontalScrollView now will spring back if smoothScrollBy scrolls out of bounds. Tweaked bounce physics for OverScroller.
Diffstat (limited to 'core/java/android/widget/ScrollView.java')
-rw-r--r--core/java/android/widget/ScrollView.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index 62797f3c384a..1a50f8589eb9 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -817,9 +817,16 @@ public class ScrollView extends FrameLayout {
* @param dy the number of pixels to scroll by on the Y axis
*/
public final void smoothScrollBy(int dx, int dy) {
+ if (getChildCount() == 0) {
+ // Nothing to do.
+ return;
+ }
long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll;
if (duration > ANIMATED_SCROLL_GAP) {
- mScroller.startScroll(mScrollX, mScrollY, dx, dy);
+ int height = getHeight() - mPaddingBottom - mPaddingTop;
+ int bottom = getChildAt(0).getHeight();
+ mScroller.startScroll(mScrollX, mScrollY, dx, dy,
+ 0, 0, 0, Math.max(0, bottom - height));
awakenScrollBars(mScroller.getDuration());
invalidate();
} else {