3

after I run my application I get large gap between RecyclerView items !! this is my code here : Github Large gap between recyclerview items

enter image description here

Ahmad Aghazadeh
  • 16,571
  • 12
  • 101
  • 98
Ridae HAMDANI
  • 686
  • 2
  • 7
  • 17

2 Answers2

11

Change your Layouts like this

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>
Uttam Panchasara
  • 5,735
  • 5
  • 25
  • 41
0

So I had the same problem but with text but I think it doesnt matter

We need to change the height of the constraint layout to wrap content instead match parent enter image description here

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – hossein Jul 27 '23 at 10:57