Ehtisham habib
Ehtisham habib

Reputation: 63

How can I use listview inside a scrollview in android?

This is the image I want in my application:

This is the image I want in my application

I tried using listview inside a scrollview but the problem is that I am not able to stretch listview to its full size. Can anyone tell me how can I do this??

Upvotes: 0

Views: 186

Answers (1)

Pragnesh Ghoda  シ
Pragnesh Ghoda シ

Reputation: 8337

You can use your recyclerview as below example :

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nestedScroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">

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

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

                <!-- Some views-->


            </LinearLayout>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recycler_bubhub_comment_list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

You can use below properties in recyclerview if you need both layout to scroll. Otherwise it would work as single scrolling view. These properties allows Recyclerview to scroll inside NestedScrollView

app:layoutManager="android.support.v7.widget.LinearLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"

Upvotes: 3

Related Questions