android - 如何在 Scrollview 中使用 Recyclerview

标签 android android-recyclerview android-scrollview

<分区>

我正在尝试在 ScrollView

中显示水平的 recyclerview 项目和垂直的 recyclerview 项目

即使我使用 android:fillViewport="true",Scrollview 也不起作用

  <ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    //Horizontal Recyclerview items
    <RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </RecyclerView>
    //vertical Recyclerview items
        <RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"></RecyclerView>
    </LinearLayout>

</ScrollView>

最佳答案

你应该使用 NestedScrollView反而。但是您可能需要编写自己的 LayoutManager。看看这个 SO Answer了解更多详情

关于android - 如何在 Scrollview 中使用 Recyclerview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34314719/

相关文章:

android - 顶点属性未传递给着色器

android - 自动回复?

android - DiffUtil 和 notificationItemInserted 之间的区别

android - RecyclerView 中的 Swipe 和 OnClick 事件

android - 约束布局中的可滚动 TextView

android - SwipeRefreshLayout 干扰 ViewPager 中的 ScrollView

Android:使用 room 创建的 SQLite 数据库在使用 sqlite-browser 打开时不显示任何表

java - 有没有办法更改上下文操作栏的背景颜色?

android - 在回收者 View 中检测上一个项目

android - 一个ScrollView不能添加多个 View 吗?