NestedScrollView smoothScroll 内的 RecyclerView

RecyclerView inside NestedScrollView smoothScroll

我在 NestedScrollView 中有一个 recyclerView。我知道这不是一个好的做法,但我需要一个滚动监听器。

侦听器包括在用户到达 recyclerView 的最终位置时发出通知。这有一个带有 3 个网格的 gridLayoutManager,可见的行数取决于屏幕的大小。

除 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>

这就是我的应用程序的运行方式。

试试这个.. recylerView.setNestedScrollingEnabled(false); 在你的 activity... 编辑 通知用户是否到达终点..使用这个

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 } } });