RecyclerView只显示第一行,其他行的距离有了,但是一片空白,这种情况我碰到的都是因为item的最外面的布局高度写为“match_parent”的原因,特此记录一下
错:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
这样就会只显示一行
正:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
博客指出RecyclerView只显示第一行,其余行空白的问题,通常是由于item最外面布局高度设为“match_parent”导致,作者特此记录该问题及错误示例。

3179

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



