运行我的应用程序后,RecyclerView项目之间存在较大的间隙!以下是我的代码:Github。请参考下方图片:Large gap between recyclerview items。
图片链接如下:
。
![enter image description here](https://istack.dev59.com/1jxSt.webp)
像这样更改您的布局
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.breuhteam.recyclerview.MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</RelativeLayout>
view_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/itemView"
android:src="@drawable/diy"
android:layout_margin="1dp"
android:adjustViewBounds="true"/>
</RelativeLayout>