I have included RecyclerView
inside NestedScrollView
and set
mRecyclerView.setNestedScrollingEnabled(false);
Since the scrolling of RecyclerView
is set to false, I will not get the scroll position of RecyclerView
due to this I will not be able to put pagination in RecyclerView
.
I have also tried this
mRecylerview.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if(dy > 0) {
totalItemCount = linearLayoutManager.getItemCount();
lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();
if (!isLoading && totalItemCount <= (lastVisibleItem + visibleThreshold)) {
// End has been reached
// Do something
if (mOnLoadMoreListener != null) {
mOnLoadMoreListener.onLoadMore();
isLoading = true;
}
}
}
}
});
But here lastVisibleItem always gives the length of the list to be displayed.
After few digging, I found that when we use RecylerView
inside NestedScrollView
all the view gets created at the very beginning so that's the reason why lastVisibleItem always gives the size of the list.
Or if I am wrong please explain, me how RecyclerView
inside NestedScrollView
works?.
Is there any workaround so that I can get RecyclerView
scroll position so that I can make my pagination work?.
It will be a great help. Thanks in advance
Here scroll is NestedScrollView