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

android – 如何使recyclerview显示所有项目,不能滚动,第1张

概述我正在制作一个应用程序,以1视图显示所有产品.我希望recyclerview显示所有项目并且无法滚动,只需滚动父视图(ScrollView).但问题是不能使回收者的高度包裹所有内容. –>>I want like this 这是我的代码:                <TextView android:text="Best seller:" android:lay 我正在制作一个应用程序,以1视图显示所有产品.我希望recyclervIEw显示所有项目并且无法滚动,只需滚动父视图(ScrollVIEw).但问题是不能使回收者的高度包裹所有内容.

–>>I want like this

这是我的代码:


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

–>>But the space is so small

解决方法 这样做是不好的做法,如果你这样做是因为标题使用了这个库
https://github.com/emilsjolander/StickyListHeaders

它会给你标题,你不需要里面有列表的滚动视图.

如果你真的想以这种方式继续使用nestedScrollVIEw而不是常规的ScrollvIEw

https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html

这将允许你像你想要的那样禁用嵌套滚动

总结

以上是内存溢出为你收集整理的android – 如何使recyclerview显示所有项目,不能滚动全部内容,希望文章能够帮你解决android – 如何使recyclerview显示所有项目,不能滚动所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1137590.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存