【问题标题】:Showing a thin line betwen cardview items在 gridview 项目之间显示细线
【发布时间】:2023-03-07 13:00:01
【问题描述】:

如上面的截图,你可以通过cardview看到项目封面的数量,但问题是card view在两个项目之间包含薄

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

【问题讨论】:

  • 那不是一条线,只是由于海拔高度而在卡片下方显示的阴影
  • 也附上你的row.xml

标签: android xml android-layout cardview


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    改变

    card_view:cardElevation="10dp"
    

    到这里:

    card_view:cardElevation="2dp"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-08
      • 2019-12-29
      • 1970-01-01
      • 1970-01-01
      • 2017-07-01
      相关资源
      最近更新 更多