ConstraintLayout 中的 ListView 在预览时展开为全屏

ListView in ConstraintLayout expands to full-screen in the preview

我正在尝试将 ListView 包含在 Android Studio 的 ConstraintLayout 中。但如果我没有指定边距,视图会在设计预览中扩展为全屏。 constraintBottom_toTopOf 参数在某些情况下没有帮助。这是 IDE 的错误还是 ListView 的工作方式?我是否可以限制 ListView 使其在另一个视图的顶部之前结束,尽管它的大小并且没有指定大边距?

这是 XML 代码:

    <ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintBottom_toTopOf="@+id/input"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"/>

设计预览:

答案:

  <ListView
     android:layout_width="match_parent"
     android:layout_height="0dp"
     app:layout_constraintBottom_toTopOf="@+id/input"
     app:layout_constraintEnd_toEndOf="parent"
     app:layout_constraintHorizontal_bias="1.0"
     app:layout_constraintStart_toStartOf="parent"
     app:layout_constraintTop_toTopOf="parent"/>