1

I have three recyclerview inside a nestedscrollview and I need that the third one keep recycling like if he was out of the nestedscrollview. It all goes great except the recycling feature is missing.

Here is my xml :

        <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/scroll_discovery"
        android:fillViewport="true"
        android:fitsSystemWindows="true"
        >
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            >
            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/category_recycler"/>
            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/category_recycler"
                android:id="@+id/user_recycler"/>
            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/user_recycler"
                android:id="@+id/experiences"/>
        </RelativeLayout>
    </android.support.v4.widget.NestedScrollView>

and here is the java part

experienceRecycler=(RecyclerView)findViewById(R.id.experiences);
    experienceRecycler.setHasFixedSize(true);
    mLayoutManager =new LinearLayoutManager(this) {
        @Override
        public boolean canScrollVertically() {
            return false;
        }
    };
    page= 1;
    experienceRecycler.setLayoutManager(mLayoutManager);
    experienceAdapter=new FeedCardAdapter(experiences,this,currentUser);
    experienceRecycler.setAdapter(experienceAdapter);
    /*experienceRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            feedCardAdapter.setScrolled(true);
        }
    });*/

    categoryRecycler=(RecyclerView)findViewById(R.id.category_recycler);
    categoryRecycler.setLayoutManager(new LinearLayoutManager(this){
        @Override
        public boolean canScrollVertically() {
            return false;
        }
    });
    categoryAdapter=new CategoryAdapter(this,categories);
    categoryRecycler.setHasFixedSize(true);
    categoryRecycler.setAdapter(categoryAdapter);

    userRecycler=(RecyclerView)findViewById(R.id.user_recycler);

    userRecycler.setLayoutManager(new LinearLayoutManager(this){
        @Override
        public boolean canScrollVertically() {
            return false;
        }
    });
    userAdapter=new UserAdapter(this,users);
    userRecycler.setAdapter(userAdapter);
    userRecycler.setHasFixedSize(true);
Jemshit
  • 9,501
  • 5
  • 69
  • 106
user1796260
  • 297
  • 1
  • 4
  • 20
  • Follow this link: http://stackoverflow.com/questions/35746113/android-recycleview-inside-scrollview – Arslan Ali May 23 '16 at 12:13
  • Thanks for the link but it generates me the following exception : `java.lang.IndexOutOfBoundsException: Invalid item position 0(0). Item count:0 at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4622) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617) at com.actvt.actvt.CustomLinearLayoutManager.measureScrapChild(CustomLinearLayoutManager.java:67) at com.actvt.actvt.CustomLinearLayoutManager.onMeasure(CustomLinearLayoutManager.java:30)` – user1796260 May 23 '16 at 12:49

1 Answers1

0

I finaly find the solution by myself. I just had a height to the recyclerview I want to keep recycling.

user1796260
  • 297
  • 1
  • 4
  • 20