如何在android中的scrollview中使用listview?

时间:2017-07-04 07:47:52

标签: java android xml listview scrollview

这是我在申请中想要的图片:

This is the image I want in my application

我尝试在scrollview中使用listview,但问题是我无法将listview扩展到其完整大小。谁能告诉我怎么能这样做?

1 个答案:

答案 0 :(得分:3)

您可以使用您的recyclerview,如下例所示:

    <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>

如果您需要同时滚动布局,则可以在recyclerview中使用以下属性。否则它将作为单个滚动视图工作。这些属性允许RecyclerviewNestedScrollView

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