Massoud Massoud - 3 months ago 12
Android Question

Space between items in custom listview

I created a very basic custom

listview
but as you can see in the images, there is a big space between items in it.
I don't know where is my fault.

My xml:

<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">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/list_item_crime_solved_checkBox"
android:padding="4dp"
android:layout_alignParentRight="true" />
<TextView
android:id="@+id/list_item_crime_title_TextBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/list_item_crime_solved_checkBox"
android:textStyle="bold"
android:padding="4dp"
tools:text="Crime Title"/>
<TextView
android:id="@+id/list_item_crime_date_TextBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/list_item_crime_solved_checkBox"
android:layout_below="@+id/list_item_crime_title_TextBox"
android:padding="4dp"
tools:text="Crime Date"/>
</RelativeLayout>

Answer

I suppose the layout you've posted here is used to inflate for each item on the list_view. So, set the layout_height of the relative layout to wrap_content.