【发布时间】:2018-05-30 23:13:21
【问题描述】:
我正在尝试在卡片视图中添加 ryclerview,以便在卡片中包含项目列表。问题是卡片内的列表现在不可滚动。
这是我的代码:
<android.support.v7.widget.CardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"">
<android.support.v7.widget.RecyclerView
android:id="@+id/records"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp" />
</android.support.v7.widget.CardView>
我尝试更改layout_width和height,没有结果并设置recyclerView.setHasFixedSize(true);
【问题讨论】:
-
你的嵌套recyclerview的方向是什么?并在 xml 文件中给它一个固定的高度
-
试试 android.support.v4.widget.NestedScrollView 这将是你的回收站视图的父级
-
您的卡片视图是在任何其他滚动视图中还是您的整个布局?
-
我的卡片视图位于约束布局内,带有另一张卡片。所以recycler view里面的卡片不能是match_parent
标签: android android-recyclerview android-cardview