Cardview - 透明背景的圆角

Cardview - rounded corners with transparent background

我正在尝试一些我认为不会花费数小时的事情。 我想要一个具有透明背景和略带圆角的卡片视图。 最后它应该是这样的(顶部的粉红色项目是其他视图):

这是我的进度:

其实我以为我已经完成了,我只需要圆角,并从卡片视图中删除笔画。好吧,看来这两件事是不可能的。当我设置 app:cardCornerRadius="8dp" 这是我得到的输出:

删除中风根本不起作用。最后,我在 drawable 中创建了一个矩形形状(我将描边设置为 0dp),将其分配给卡片视图,描边消失了,但圆角后面有一个白色背景,我无法将其删除。

这是我的 CardView 布局:

<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_margin="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:elevation="0dp"
app:cardCornerRadius="8dp"
app:cardPreventCornerOverlap="true"
app:cardBackgroundColor="#00123456"
> </CardView>

有没有可能实现我想要的(第一张图片)?还是应该放开RecyclerView切换成ListView?

删除作为父级的 CardView 并放置一个 Constraintlayout,问题解决了。

<androidx.constraintlayout.widget.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:background="@drawable/rounded_background"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
android:paddingTop="4dp"></ConstraintLayout>