7

When I use RecyclerView inside NestedScrollView, then I use like scrollTo() fixed position, it's not working.

(rlv_brandWithLetter.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(index, 0)
rlv_brandWithLetter.smoothScrollToPosition(index)

I read the source code of NestedScrollView,the method scrollTo() was executed.

@Override
public void scrollTo(int x, int y) {
    if (getChildCount() > 0) {
        View child = getChildAt(0);
        x = clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth());
        y = clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight());
        if (x != getScrollX() || y != getScrollY()) {
            super.scrollTo(x, y);
        }
    }
}

But x != getScrollX() || y != getScrollY() always return false,this is the clue that I found.

Has anyone ever met this problem?

hiddeneyes02
  • 2,562
  • 1
  • 31
  • 58
Stephen
  • 81
  • 2
  • Did you ever figure this out? I'm having a similar issue https://stackoverflow.com/questions/53876952/nestedscrollview-coodinatorlayout-scrollby-scrollto-methods-do-nothing – tenprint Jan 03 '19 at 15:44

0 Answers0