CardView 圆角获得意想不到的白色

Asi*_*Das 7 android android-layout

在 CardView 中使用圆角时,在圆角区域显示白色边框,这在黑暗环境中最常见。为了更容易理解,请检查附加的图像吹。在此处输入图片说明

这是 xml

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorTransparent"
    android:orientation="vertical"
    android:padding="4sp">


    <androidx.cardview.widget.CardView
        android:id="@+id/image_view_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="20dp"
        android:background="@color/colorTransparent"
        app:cardCornerRadius="20dp"
        app:cardElevation="4dp">


        <ImageView
            android:id="@+id/iv_themes"
            android:layout_width="match_parent"
            android:layout_height="110dp"
            android:background="@color/colorTransparent"
            android:gravity="center"
            android:scaleType="centerCrop"
            android:src="@mipmap/tm_2_mip_background" />

    </androidx.cardview.widget.CardView>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Dan*_*iel 7

我最近遇到了同样的问题。添加app:cardBackgroundColor="@color/transparent"到 CardView 就成功了。