Use RecyclerView inside ScrollView with flexible Recycler item height

Ashkan picture Ashkan · Sep 6, 2015 · Viewed 36.6k times · Source

I want to know if there is any possible way to use RecyclerView?

Before this, I used RecyclerView with fixed height inside a ScrollView but this time I don't know the height of the item.

Hint: I read all question and solution on stack question before asking this question.

update: Some solution show how to scroll RecyclerView on its own but I want to show it expanded.

Answer

Bhunnu Baba picture Bhunnu Baba · Oct 15, 2016

If you want to just scrolling then you can use to NestedScrollView instead of ScrollView So you can modify your code with following :

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

            //design your content here with RecyclerView 

    </LinearLayout>

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