RecyclerView that does not scroll and shows all items

Solution 1:

It’s pretty simple, simply set the RecyclerView’s height to wrap_content.

You might also benefit from disabling nested scrolling on the recycler view, like so:

RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
recycler.setNestedScrollingEnabled(false);

Solution 2:

The solution of setNestedScrollingEnabled(false) isn't as full as it should: you need to use NestedScrollView instead of ScrollViewfocusableInTouchMode="true" to the child of the NestedScrollView .

If you insist on using ScrollView, you should also set minHeight to the RecyclerView, and also set overScrollMode="never" . In this case, it still isn't a good solution because the minHeight might not be enough in some cases

Other alternative solutions that you should consider:

  1. Replace the ScrollView&RecyclerView with a single RecyclerView, which has views with additional view type for what you had in the ScrollView

  2. Use GridLayout or another layout instead.

Solution 3:

Maybe it is not completely clear at first sight what to do with all these answers. I just tried them and the working one is:

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/person_properties"
        android:orientation="vertical"
        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:overScrollMode="never" />
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

No need to change anything programmatically.

Solution 4:

In your activity.xml file

<androidx.core.widget.NestedScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ActivityName">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/RecyclerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:nestedScrollingEnabled="false">

     </androidx.recyclerview.widget.RecyclerView>

</androidx.core.widget.NestedScrollView>

In RecyclerView use android:nestedSrollingEnabled="false" and use NestedScrollView as a parent Scroll View.