Ambran Ambran - 1 month ago 14
Android Question

Android: Gap between CardView elements in ListView

I can't seem to increase the gap between the CardView elements in my ListView. I tried adding

android:layout_marginBottom="16dp"
to the CardView but that doesn't do anything. I'me using SDK 23. Any Idea what I can do?

Here is the card layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp" <!-- Not Working -->
card_view:cardCornerRadius="@dimen/cardview_default_radius"
card_view:cardElevation="@dimen/cardview_default_elevation"
card_view:cardUseCompatPadding="true"
card_view:contentPadding="@dimen/abc_action_bar_content_inset_material">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

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

<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/tip_detail_date"
android:textSize="14sp"
android:textStyle="bold" />

<TextView
android:id="@+id/text_tip_dato"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>

Answer

Change yout listview some thing like this

 <ListView 
    android:id="@+id/ListView01" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:divider="@color/redBackground"
    android:dividerHeight="1dip">// Increase this height as your need
 </ListView>
Comments