diff options
author | Winson Chung <winsonc@google.com> | 2011-09-09 11:44:31 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-09-09 11:45:50 -0700 |
commit | 09c1552341d76f9963eb18245887d86c4d00301f (patch) | |
tree | a76d6631f4dddd4eb0ff0b87cd1550163a94d9d7 /src | |
parent | a1c7ff12192b3bf670f7870f22b0f9b8ed161289 (diff) | |
download | android_packages_apps_Trebuchet-09c1552341d76f9963eb18245887d86c4d00301f.tar.gz android_packages_apps_Trebuchet-09c1552341d76f9963eb18245887d86c4d00301f.tar.bz2 android_packages_apps_Trebuchet-09c1552341d76f9963eb18245887d86c4d00301f.zip |
Bounding scroll bar to the track to prevent overscrolling.
Change-Id: I2db815e072dcf41dda8102829d136fc2dca588e7
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 807470c70..9f9450c4d 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -1776,11 +1776,13 @@ public abstract class PagedView extends ViewGroup { int numPages = getChildCount(); int pageWidth = getMeasuredWidth(); int maxPageWidth = (numPages * getChildWidth(0)) + ((numPages - 1) * mPageSpacing); + int maxScrollPosition = maxPageWidth - pageWidth; // n-1 * pageWidth int trackWidth = pageWidth - mScrollIndicatorPaddingLeft - mScrollIndicatorPaddingRight; int indicatorWidth = mScrollIndicator.getMeasuredWidth() - mScrollIndicator.getPaddingLeft() - mScrollIndicator.getPaddingRight(); - float offset = (float) getScrollX() / maxPageWidth; + float offset = (float) Math.max(0f, Math.min(maxScrollPosition, getScrollX())) + / maxPageWidth; int indicatorSpace = trackWidth / numPages; int indicatorPos = (int) (offset * trackWidth) + mScrollIndicatorPaddingLeft; if (hasElasticScrollIndicator()) { |