【问题标题】:How can I use listview inside a scrollview in android?如何在 android 的滚动视图中使用列表视图?
【发布时间】:2017-07-04 07:47:51
【问题描述】:

这是我想要在我的应用程序中使用的图像:

我尝试在滚动视图中使用列表视图,但问题是我无法将列表视图拉伸到完整大小。谁能告诉我该怎么做??

【问题讨论】:

  • NestedScrollViewRecyclerView 是最好的选择。
  • 你有什么例子吗?如果有,请与我分享
  • 不需要任何教程。只需将RecyclerView 放入NestedScrollView
  • 在另一个卷轴中使用一个卷轴是个坏主意。只需将所有视图添加到 ScrollView 中即可。
  • 但我需要教程

标签: java android xml listview scrollview


【解决方案1】:

你可以使用你的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"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-24
    • 2014-09-04
    • 1970-01-01
    • 1970-01-01
    • 2015-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多