Reputation: 3956
I have this situation. I implemented endless scrolling with RecyclerView. Normally new items are suppose to load when there are only 5 items below the current scroll position but this is not so.
Rather As soon as the first set of items are loaded from the API, another is sent (without scrolling), received and parsed . After which yet another request is sent (still without scrolling) and parsed. This process continues (without scrolling) until the app is exited.
My RecyclerView
mLayoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new FadeInLeftAnimator());
recyclerView.setNestedScrollingEnabled(false);
adapter = new PostAdapter(mPostItemList, getActivity());
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new EndlessRecyclerViewScrollListener( mLayoutManager) {
@Override
public void onLoadMore(final int page, int totalItemsCount, RecyclerView view) {
Log.w(TAG, "onLoadMore called");
morePostsUrl = postUrl + "&page=" + page;
getMorePostArray(morePostsUrl, true, false);
}
});
Upvotes: 2
Views: 912
Reputation: 11
Turns out that this is a problem if you have a <ScrollView>
in your layout (not only NestedScrollView
).
Removing the ScrollView
solved the problem for me!
Btw: This was only a problem when testing on older phones...
Tested with Samsung Galaxy S3 -> You must remove the ScrollView
Tested with Samsung Galaxy S8 -> Works fine with ScrollView
Upvotes: 1
Reputation: 3956
I discovered that the problem is that the RecyclerView has a NestedScrollView as a parent. When I removed the NestedScrollView, this problem stopped.
Upvotes: 2