RecyclerView项目之间的差距很大

时间:2016-09-13 18:19:30

标签: android xml android-recyclerview

运行我的应用程序后,我在RecyclerView项目之间存在很大差距! 这是我的代码:Github Large gap between recyclerview items

enter image description here

1 个答案:

答案 0 :(得分:6)

像这样更改你的布局

<强> 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>