1

I have used Recycler View Inside Nested Scroll View(which is within CoordinatorLayout):

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/sections_recycler_view_linearlayout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical" />

            </RelativeLayout>

        </android.support.v4.widget.NestedScrollView>

Within the adapter of above recycler I have added Child Recycler Views programatically using setNestedScrollingEnabled as false.

My Issue is: When I am scrolling the child recycler, as soon as its scroll is completed the parent recycler scrolls to top, as if I am setting its adapter again. I have not added any code to notify adapter or to scroll to top-most recycler item or to set adapter again. I could not figure out the reason for this strange behavior.

Any help would be highly appreciated.. !!!

user3492435
  • 846
  • 2
  • 10
  • 24
  • Why do you even need this structure? A single recycleview could do the same. – breakline Sep 07 '16 at 09:11
  • Because I want parent recycler to scroll vertically while child recyclers with scroll horizontally. The parent recycler is been used with Collapsable Toolbar to show Toolbar animations and it will be decided in runtime how many child will be there in Parent Recycler View. – user3492435 Sep 07 '16 at 10:06
  • Child Recycler Stucks when scrolling even if I remove setHasFixedSize or even if I set it as true or false. – user3492435 Sep 07 '16 at 10:10
  • 1
    Check this, it might help, I had a similar issue: http://stackoverflow.com/questions/36923948/recycleview-steals-focus-when-inside-a-nestedscrollview – breakline Sep 07 '16 at 10:23

3 Answers3

1

Add to your parent Recycler View:

android:descendantFocusability="blocksDescendants"
lebelinoz
  • 4,380
  • 9
  • 27
  • 52
0

I was display progress bar in child recycler views until I receive data from server. And once I get data I was populating it. I had used staggered Adapter for child recyclers with row count 2 and hence after data got populated my parent recyler's height was changing.

I used setHasFixedSize(false) for parent recycler view as its height was changing and I have not seen the issue again till now.

user3492435
  • 846
  • 2
  • 10
  • 24
0

Easy, Add

android:fillViewport="true"

to your NestedScrollview and you will be good to go.

Sandip Savaliya
  • 718
  • 6
  • 19