Ryan Ryan - 3 years ago 45
Android Question

Removing space between recyclerview items

I have searched around and they all mention about changing the

layout_height
to
wrap_content
but mine is already in
wrap_content
. I really can't identify any error. Any help is welcome. Thanks in advance!

Screenshot of problem

<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="wrap_content"
tools:context="com.fyp.ipptapp.UI.StandardFragment">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<LinearLayout
android:id="@+id/test"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:text="Age" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:text="Gender" />
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<Spinner
android:id="@+id/spinner_Age"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_margin="5dp"
android:dropDownWidth="50dp" />

<Spinner
android:id="@+id/spinner_Gender"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_margin="5dp"
android:dropDownWidth="50dp" />

</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:text="Voc" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:padding="15dp"
android:text="Pop Gp" />

</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<Spinner
android:id="@+id/spinner_Voc"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_margin="5dp"
android:dropDownWidth="200dp" />

<Spinner
android:id="@+id/spinner_PopGp"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_margin="5dp"
android:dropDownWidth="120dp" />

</LinearLayout>
</LinearLayout>

<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/test"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:text="Exemption" />

<CheckBox
android:id="@+id/pushUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Push Up" />

<CheckBox
android:id="@+id/sitUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sit Up" />
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/linearLayout2">

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/linearLayout2" />

</LinearLayout>
</RelativeLayout>



Answer Source

In your adapter xml parent layout height might be set to match_parent. Check it once

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download