其实只要布局中的recyclerView外面加上一层相对布局就可以了。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<!-- DEV NOTE: Outer wrapper relative layout is added intentionally to address issue
that only happens on Marshmallow & Nougat devices (API 23 & 24).
On marshmallow API 23, the "RecyclerView" `layout_height="wrap_content"` does NOT
occupy the height of all the elements added to it via adapter. The result is cut out
items that is outside of device viewport when it loads initially.
Wrapping "RecyclerView" with "RelativeLayout" fixes the issue on Marshmallow devices.
-->
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/row_list_item">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
[java] view plain copy
[java] view plain copy
mPlateView.setLayoutManager(new GridLayoutManager(this, 3) {
@Override
public boolean canScrollVertically() {
return false;
}
});
mPlateView.setNestedScrollingEnabled(false);
//blog.youkuaiyun.com/ShareUs/article/details/53840407
Android 6.0 scrollview 嵌套recyclerview不能全部显示,高度不正常的问题
最新推荐文章于 2021-05-25 18:15:52 发布
本文介绍了解决Android中RecyclerView在特定API版本下无法正确显示所有项的问题。通过将RecyclerView包裹在一个RelativeLayout中,并设置适当的属性,可以确保组件能适配其内容的高度。
1180

被折叠的 条评论
为什么被折叠?



