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?