Android RecyclerView显示在ConstraintLayout 2.0.0-beta7上,但显示在1.1.3上

Android RecyclerView显示在ConstraintLayout 2.0.0-beta7上,但显示在1.1.3上,android,android-recyclerview,android-constraintlayout,android-jetpack,Android,Android Recyclerview,Android Constraintlayout,Android Jetpack,我有一个循环视图在一个约束窗口内。一切都显示出来,工作正常 问题是2.0.0-beta7的性能非常差,所以我决定将其降级为稳定版本,即1.1.3。性能非常好,但现在的问题是没有显示recyclerView recyclerView有一个wrap_内容高度,但在Layout Inspector上选中时,显示为0。我错过什么了吗 <androidx.recyclerview.widget.RecyclerView android:id="@+id/recycler&q

我有一个循环视图在一个约束窗口内。一切都显示出来,工作正常

问题是2.0.0-beta7的性能非常差,所以我决定将其降级为稳定版本,即1.1.3。性能非常好,但现在的问题是没有显示recyclerView

recyclerView有一个wrap_内容高度,但在Layout Inspector上选中时,显示为0。我错过什么了吗

<androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:clipToPadding="false"
        android:orientation="horizontal"
        android:paddingStart="8dp"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/toolbar_layout"
        tools:listitem="@layout/radio_button" />

在使用
ConstraintLayout
时,我们往往会遗漏一些东西。其中一个是在apt时使用
0dp
,另一个是对几乎所有方向进行约束

您尚未对视图的底部设置任何约束

<androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:clipToPadding="false"
        android:orientation="horizontal"
        android:paddingStart="8dp"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/toolbar_layout"
        app:layout_constraintVertical_bias="0.0"
        tools:listitem="@layout/radio_button" />

如果您希望您的回收器视图位于
工具栏\u布局
和父级底部的中心,您可以删除
应用程序:布局\u约束垂直\u bias=“0.0”
。如果希望“回收器”视图保持在父视图的底部,可以将“偏差”的值更改为“1.0”


另外,请确保您使用的方向正确。如果方向应该是水平的,您可能需要将布局的宽度更改为
0dp
match\u parent

您是对的。在我的例子中,我需要降低库的级别(不要使用beta版),并使用
0dp
作为高度和宽度。此外,由于底部视图被约束到顶部和底部,因此不会约束到底部。因为如果我将它们全部约束在顶部和底部,将显示警告。