diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java index f0d6de20f6..883cbeed9c 100644 --- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java +++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java @@ -175,6 +175,7 @@ public class RecyclerViewFastScroller extends View { if (mThumbOffsetY == y) { return; } + updatePopupY((int) y); mThumbOffsetY = y; invalidate(); } @@ -281,7 +282,6 @@ public class RecyclerViewFastScroller extends View { mPopupView.setText(sectionName); } animatePopupVisibility(!sectionName.isEmpty()); - updatePopupY(lastY); mLastTouchY = boundedY; setThumbOffsetY((int) mLastTouchY); } @@ -299,11 +299,14 @@ public class RecyclerViewFastScroller extends View { canvas.translate(0, mThumbOffsetY); halfW += mThumbPadding; - float r = mWidth + mThumbPadding + mThumbPadding; + float r = getScrollThumbRadius(); canvas.drawRoundRect(-halfW, 0, halfW, mThumbHeight, r, r, mThumbPaint); canvas.restoreToCount(saveCount); } + private float getScrollThumbRadius() { + return mWidth + mThumbPadding + mThumbPadding; + } /** * Animates the width of the scrollbar. @@ -352,11 +355,15 @@ public class RecyclerViewFastScroller extends View { } private void updatePopupY(int lastTouchY) { + if (!mPopupVisible) { + return; + } int height = mPopupView.getHeight(); - float top = lastTouchY - (FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR * height) - + mRv.getScrollBarTop(); - top = Utilities.boundToRange(top, - mMaxWidth, mRv.getScrollbarTrackHeight() - mMaxWidth - height); + // Aligns the rounded corner of the pop up with the top of the thumb. + float top = mRv.getScrollBarTop() + lastTouchY + (getScrollThumbRadius() / 2f) + - (height / 2f); + top = Utilities.boundToRange(top, 0, + getTop() + mRv.getScrollBarTop() + mRv.getScrollbarTrackHeight() - height); mPopupView.setTranslationY(top); }