Ridae HAMDANI
Ridae HAMDANI

Reputation: 746

Large gap between RecyclerView items

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

Upvotes: 3

Views: 5478

Answers (2)

Matrix Gaming
Matrix Gaming

Reputation: 3

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

Upvotes: 0

Uttam Panchasara
Uttam Panchasara

Reputation: 5865

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>

Upvotes: 11

Related Questions