Bart Bergmans Bart Bergmans - 1 month ago 30x
Android Question

Recyclerview inside ScrollView not scrolling smoothly

For my app I am using a Recyclerview inside a Scrollview where the Recyclerview has a height based on its content using this library. Scrolling is working but it's not working smoothly when I scroll over the Recyclerview. When I scroll over the Scrollview itself it is scrolling smoothly.

The code I am using to define the Recyclerview:

LinearLayoutManager friendsLayoutManager = new LinearLayoutManager(getActivity().getApplicationContext(),, false);
mFriendsListView.addItemDecoration(new DividerItemDecoration(getActivity().getApplicationContext(), null));

The recyclerview in the scrollview:

android:layout_height="wrap_content" />


Try doing:

RecyclerView v = (RecyclerView) findViewById(...);

As an alternative, you can modify your layout using the support design library. I guess your current layout is something like:

<ScrollView >
   <LinearLayout >

       <View > <!-- upper content -->
       <RecyclerView > <!-- with custom layoutmanager -->

   </LinearLayout >
</ScrollView >

You can modify that to:

<CoordinatorLayout >

    <AppBarLayout >
        <CollapsingToolbarLayout >
             <!-- with your content, and layout_scrollFlags="scroll" -->
        </CollapsingToolbarLayout >
    </AppBarLayout >

    <RecyclerView > <!-- with standard layoutManager -->

</CoordinatorLayout >

However this is a longer road to take, and if you are OK with the custom linear layout manager, then just disable nested scrolling on the recycler view.

Edit (4/3/2016)

The v 23.2 release of the support libraries now includes a factory “wrap content” feature in all default LayoutManagers. I didn’t test it, but you should probably prefer it to that library you were using.