在 ScrollView 中使用 RecyclerView 并具有灵活的 Recycler 项目高度

2024-03-17

我想知道是否有任何可能的方法可以使用回收视图?

在此之前,我使用 RecyclerView固定高度里面一个滚动视图但这次我不知道该物品的高度。

Hint:在问这个问题之前,我阅读了堆栈问题上的所有问题和解决方案。

update:一些解决方案展示了如何滚动回收视图就其本身而言,但我想展示它的扩展。


如果你只想滚动那么你可以使用嵌套滚动视图代替滚动视图因此,您可以使用以下方式修改您的代码:

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

            //design your content here with RecyclerView 

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 ScrollView 中使用 RecyclerView 并具有灵活的 Recycler 项目高度 的相关文章

随机推荐