Paginate with Nested Scroll View?
See original GitHub issueHello, Marko. Thank you very much for the great lib. It’s working great for me and you save me a lot of time and effort. I have two fragments. In the first one I have a recycle view only and I use Paginate and it works just great. In the second fragment I have a Nested scroll view like this:
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/profileBg">
<android.support.v7.widget.RecyclerView android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:background="@color/profileBg"
xmlns:android="http://schemas.android.com/apk/res/android" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
-------------------------------------------------------------------------------------------
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
layoutManager.setAutoMeasureEnabled(true);
adapter = new PostAdapter(mContext, posts, this);
list.setLayoutManager(layoutManager);
list.setNestedScrollingEnabled(false);
list.addItemDecoration(new SpacesItemDecoration((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, mContext.getResources().getDisplayMetrics())));
list.setAdapter(adapter);
callbacks = new Paginate.Callbacks() {
@Override
public void onLoadMore() {
loading = true;
OFFSET += LIMIT;
loadNextDataFromApi(OFFSET);
}
@Override
public boolean isLoading() {
return loading;
}
@Override
public boolean hasLoadedAllItems() {
return false;
}
};
paginate = Paginate.with(list, callbacks)
.setLoadingTriggerThreshold(8)
.build();
I also tried without:
layoutManager.setAutoMeasureEnabled(true);
list.setNestedScrollingEnabled(false);
but the result is the same. I use the same logic in the two places but when it’s in the nested scroll view scrolling becomes really slow and finally app just stop working. Without the Paginate it’s work fine. Do you have any suggestions for this bug? Thank you very much!
Update: I set a break point and found that with NestedScrollView it enters in the callback infinity times even without scrolling. I hope this can help you finding the problem.
Update 2: The same problem when embedded in a CordinatorLayout.
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (2 by maintainers)

Top Related StackOverflow Question
I had the same problem and found the solution. Replace your NestedScrollView with LinearLayout like that:
Don’t forget to add
app:layout_behavior="@string/appbar_scrolling_view_behavior"andandroid:layout_height="wrap_content"to attributes!If you use RecyclerView inside NestedScrollView, layout manager can’t measure it’s height and set it infinite. So paginate will load data until all will be loaded even if you won’t scroll the list. With linear layout the height is measured and paginate will load data only if you scroll to the bottom of list.
Is this issue solved?? I am also facing problems using pagination in NestedScrollView.