Android:ListView中的CardView元素之间的差距

问题描述:

我似乎无法增加ListView中CardView元素之间的差距。我试图在CardView中添加android:layout_marginBottom="16dp",但这没有任何作用。我使用SDK 23.任何想法我可以做什么?Android:ListView中的CardView元素之间的差距

这里是卡片布局:

<?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> 

变化YOUT的ListView一些这样的事

<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> 

对于API 23.你需要设置

app:cardUseCompatPadding="true" 

在您的卡片视图

+0

我在那里e代码... – Ambran

+0

然后尝试添加:card_view:cardPreventCornerOverlap =“false” –