Android Recyclerview溢出约束

Android Recyclerview溢出约束,android,android-recyclerview,android-constraintlayout,Android,Android Recyclerview,Android Constraintlayout,我正在尝试创建一个recyclerview,它的大小随着附加项目的增加而增加,直到达到某个最大高度,然后逐渐消失。我知道Constraint layout是正确的方式,我发誓它在一个月前就已经开始工作了,然后Recyclerview就不再关心它的约束,并且在280dp之后仍然可见(见图)。这是我的密码。我确信这已经起作用了,我不知道谷歌是否将一些东西改成了“androidx.constraintlayout:constraintlayout:2.0.0-beta4”的实现,或者我是否正在慢慢发疯

我正在尝试创建一个recyclerview,它的大小随着附加项目的增加而增加,直到达到某个最大高度,然后逐渐消失。我知道Constraint layout是正确的方式,我发誓它在一个月前就已经开始工作了,然后Recyclerview就不再关心它的约束,并且在280dp之后仍然可见(见图)。这是我的密码。我确信这已经起作用了,我不知道谷歌是否将一些东西改成了“androidx.constraintlayout:constraintlayout:2.0.0-beta4”的实现,或者我是否正在慢慢发疯。也许有人知道如何解决这个问题。可能是因为实现是测试版。任何帮助都将不胜感激

<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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_tilemap"
android:layout_width="match_parent"
android:layout_height="wrap_content">


    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintHeight_default="wrap"
        app:layout_constraintHeight_max="280dp"
        app:layout_constrainedHeight="true"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:fadingEdge="horizontal"
        android:fadingEdgeLength="30dp"
        android:fillViewport="true"
        android:requiresFadingEdge="vertical"
        android:id="@+id/rv_comms"
        android:padding="0dp"
        android:clipToPadding="false" />


</androidx.constraintlayout.widget.ConstraintLayout>

我刚刚找到了该负责的代码。原来是我的适配器中的录音按钮造成的。它们包括以下方法,使按钮能够溢出其他适配器项的视图(按下按钮时,按钮将像whatsapp中一样增长,请参见下图)

该方法的递归性质(在该方法的最后4行中已经注释掉)基本上将CliptPadding和clipChildren从record按钮向上的整个视图层次设置为false,这会导致奇怪的溢出。最后,我手动将clipToPadding和clipChildren设置为false,仅用于与适配器相关的视图(这允许我保留很酷的录制按钮溢出动画,而不会出现褪色边缘问题),现在它看起来很漂亮(见下文)


您希望您的布局实际如何?在上图中,您可以看到最后一个项目上的淡入淡出的边缘。问题在于,该项在该衰退边缘之外仍然可见。正如你所看到的,它与我的指南针重叠,事实上,它应该在指南针上方不再可见
public void setClip(View v) {
    if (v.getParent() == null) {
        return;
    }

    if (v instanceof ViewGroup) {
        ((ViewGroup) v).setClipChildren(false);
        ((ViewGroup) v).setClipToPadding(false);
    }

    if (v.getParent() instanceof View) {//this part is to blame
        setClip((View) v.getParent());
    }
}