Android使用ConstraintLayout绘制界面的问题


<?xml version="1.0" encoding="utf-8"?>
<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">

    <ImageView
        android:id="@+id/bg_image"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@+id/card_layout"
        app:layout_constraintBottom_toBottomOf="@+id/card_layout"
        android:scaleType="centerCrop"
        app:riv_corner_radius="12dp" />

    <LinearLayout
        android:id="@+id/card_layout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:orientation="vertical">

        ...xxxx....

    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

如何设置才能让ImageView的高度跟下面LineaerLayout的高度一致?因为LineaerLayout的高度不定,我想让ImageView做LinearLayout的背景图片,这个设置似乎不起作用,请教一下大家谢谢🙏

直接设置LinearLayout的background属性,或者把imageView放到LinearLayout里面,高度撑满父布局