小编Kul*_*Ken的帖子

如何使recyclerview显示所有项目,不能滚动

我正在制作一个应用程序,以1视图显示所有产品.我希望recyclerview显示所有项目并且无法滚动,只需滚动父视图(ScrollView).但问题是不能使回收者的高度包裹所有内容.

- >>我想要这样

这是我的代码:

    <TextView
        android:text="Best seller:"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView4"
        android:textColor="#3f3f3f"
        android:textSize="18sp" />

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:scrollbars="horizontal"
        android:id="@+id/rv_bestSeller"
        android:layout_height="200dp" />

    <TextView
        android:text="New Product"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView5"
        android:textSize="18sp"
        android:textColor="#3f3f3f" />

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:scrollbars="horizontal"
        android:layout_height="200dp"
        android:id="@+id/rv_newProduct"/>

    <TextView
        android:text="All Product"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView6"
        android:textSize="18sp"
        android:textColor="#3f3f3f" />
    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/rv_allProduct" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

- >>但空间太小了

android scroll android-recyclerview

11
推荐指数
2
解决办法
7957
查看次数

标签 统计

android ×1

android-recyclerview ×1

scroll ×1