I have a recyclerView inside a NestedScrollView. I know this is not a good practice, but I need a listener for the scroll.
The listener consists on notify when the user reached the final of the recyclerView. This have a gridLayoutManager with 3 grids and the number of rows visible depends of the size of the screen.
Everything works but the smoothScroll.
<android.support.v4.widget.NestedScrollView
android:id="@+id/nestedGalleryAll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<android.support.v7.widget.RecyclerView
android:id="@+id/galleryAll"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
This is how is working my app.
Try this.. recylerView.setNestedScrollingEnabled(false);
in your activity....
Edit To notify user if he reached end..use this
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
{
LinearLayoutManager layoutManager=LinearLayoutManager.class.cast(recyclerView.getLayoutManager());
int totalItemCount = layoutManager.getItemCount();
int lastVisible =
layoutManager.
findLastVisibleItemPosition(); boolean
endHasBeenReached
= lastVisible + 5
>= totalItemCount;
if (totalItemCount > 0 && endHasBeenReached)
{ //you have reached to the bottom of your recycler view } } });