无法阻止 RecyclerView 中的 CardView 剪辑孩子

Cannot prevent CardView in RecyclerView to clip childs

我试图将 ImageView 稍微移出 cardView,但 cardview 一直在剪裁 child。

我有以下 XML 结构:

<RecyclerView>
    <CardView>
         <LinearLayout>
              <LinearLayout>
                   <ImageView/>
                   ...

我已将所有容器设置为:

clipToPadding="false"
clipChildren="false"

除了 RecyclerView 之外的所有东西都得到了 setClipToOutline="false"

在 cardView 的顶部有 cardUseCompatPadding="true"

Android Studio 预测如下:
Screenshot out of Android Studio(所以防止图像,因为我是新来的,名声不大..)

但无论出于何种原因,在我的 phone(Galaxy A3、Lineage OS、Android 9)上,图像视图仍然被裁剪。

知道如何不仅在 Android Studio 中而且在我的 phone 中获得所需的行为吗?


更新

card_view.xml

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:cardView="http://schemas.android.com/tools">

<data>
    <variable name="..."
        type="..."/>
</data>

<androidx.cardview.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    app:cardElevation="0dp"
    app:cardCornerRadius="5dp"
    app:cardUseCompatPadding="true"
    android:clipToPadding="false"
    android:clipChildren="false"
    cardView:setClipToOutline="false">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipToPadding="false"
        android:clipChildren="false"
        cardView:setClipToOutline="false"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="70dp"
            android:layout_marginBottom="5dp"
            android:clipToPadding="false"
            android:clipChildren="false"
            cardView:setClipToOutline="false"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/card_view_flag"
                android:layout_width="50dp"
                android:layout_height="match_parent"
                android:layout_margin="3dp"
                android:translationY="-10dp"
                android:clipToPadding="false"
                cardView:setClipToOutline="false"
                android:src="@drawable/colored_flag"/>


            <TextView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"/>

            <CheckBox
                style="?android:attr/starStyle"
                android:scaleX="1.5"
                android:scaleY="1.5"
                android:layout_marginEnd="5dp"
                android:layout_width="35dp"
                android:layout_height="match_parent" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:orientation="horizontal">

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"/>

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1.5"/>

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginStart="10dp"
                android:layout_marginLeft="10dp"/>

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1.5"/>
        </LinearLayout>

    </LinearLayout>
</androidx.cardview.widget.CardView>
</layout>

recyclerview..

<androidx.recyclerview.widget.RecyclerView
                android:id="@+id/recycler_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clipToPadding="false"
                android:clipChildren="false"
                android:paddingBottom="70dp"
                android:scrollbars="vertical" />

你所要做的就是将图像放在 cardView 之外

<ConstraintLayout>
    <CardView>
    <ImageView/>

只是给出一个格式正确的完整结果,说明@Sinner 引导我的结果...

因为我的 ViewHolder 是这样膨胀的:

@Override
public ListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                       int viewType)
{
    CardView v = (CardView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.list_card, parent, false);

    ViewHolder vh = new ViewHolder(v);
    return vh;
}

我一直在下游使用 CardView,我这样修改了@Sinners 的答案以使其工作:

<CardView>
    <ConstraintLayout>
        <CardView>
        <ImageView/>

外层 CardView 是透明的,ConstrainLayout 有内边距和 clipToPadding="false"。然后 ImageView 可以位于内部 CardView 之外并看起来像预期的那样:)

谢谢!