首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RecyclerView inside smoothScroll

RecyclerView inside smoothScroll
EN

Stack Overflow用户
提问于 2018-02-19 17:52:15
回答 1查看 637关注 0票数 0

我在recyclerView里面有一个NestedScrollView。我知道这不是一个好的实践,但我需要一个听众的卷轴。

侦听器包括当用户到达recyclerView的最终结果时通知。它有一个带有3个网格的gridLayoutManager,可见的行数取决于屏幕的大小。

除了smoothScroll,一切都正常。

代码语言:javascript
复制
<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>

这就是我的应用程序的工作方式。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-19 17:57:31

试试这个..。recylerView.setNestedScrollingEnabled(false);在你的活动中..。编辑通知用户,如果他到达end..use

代码语言:javascript
复制
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 } } });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48871641

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档