Search code examples
androidjsonscrollandroid-recyclerview

When Scrolling in RecyclerView automatically adds space in between rows


I have used RecyclerView to display some JSON data using Volley Library. I am getting the JSON data, but initially when data is displayed, it is in correct format. But when I scroll in recyclerview, then huge space is added in between rows.

Before Scrolling Before Scolling

enter image description here

After Scrolling Here is the XMl Part of row.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="match_parent">
<TextView
    android:id="@+id/tv_title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/iv_image"
    android:textSize="18sp"
    />
</RelativeLayout>

Here is the recyclerview added in xml

 <android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    />
</android.support.design.widget.CoordinatorLayout>

Thanks in advance.


Solution

  • Change your relativelayout's height to wrap_content in row.xml

      android:layout_height="wrap_content "