在cardview项目之间显示细线

时间:2019-06-08 11:07:36

标签: android xml android-layout cardview

enter image description here

如上图所示,您可以通过卡片视图看到物品覆盖的数量,但是问题是卡片视图在两个物品之间包含稀薄的物体

我如何删除这条细线,我的cardview 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="wrap_content">

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="5dp"
        card_view:cardPreventCornerOverlap="true"
        card_view:cardElevation="10dp"
        card_view:cardBackgroundColor="@color/white"
        card_view:cardCornerRadius="4dp">

    </android.support.v7.widget.CardView>
</RelativeLayout>

2 个答案:

答案 0 :(得分:5)

您必须降低卡的高度。如下更改代码

<?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="wrap_content">

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="5dp"
        card_view:cardPreventCornerOverlap="true"
        card_view:cardElevation="2dp"
        card_view:cardBackgroundColor="@color/white"
        card_view:cardCornerRadius="4dp">

    </android.support.v7.widget.CardView>
</RelativeLayout>

答案 1 :(得分:2)

更改

card_view:cardElevation="10dp"

对此:

card_view:cardElevation="2dp"