Android 约束展开重叠视图

Android 约束展开重叠视图,android,android-constraintlayout,Android,Android Constraintlayout,我目前有两个卡片布局,一个在另一个下面。每张卡都包含一个约束布局,并且每张卡都包含自己的子卡。这两张卡位于主约束布局内。 我把第二张卡叫做主卡,放在第一张卡叫做信息卡的下面。 问题是主卡和信息卡重叠,我不知道为什么。屏幕下方: 这是我关于这两个视图的XML文件: <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app=

我目前有两个卡片布局,一个在另一个下面。每张卡都包含一个约束布局,并且每张卡都包含自己的子卡。这两张卡位于主约束布局内。 我把第二张卡叫做主卡,放在第一张卡叫做信息卡的下面。 问题是主卡和信息卡重叠,我不知道为什么。屏幕下方:

这是我关于这两个视图的XML文件:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/constraintlayout_sendaudio_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/backgroundColor">

<android.support.v7.widget.CardView
    android:id="@+id/cardview_sendaudio_info"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/constraintlayout_sendaudio_info"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        .. Its child

    </android.support.constraint.ConstraintLayout>

</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
    android:id="@+id/cardview_sendaudio_maincard"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginBottom="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/cardview_sendaudio_info">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/constraintlayout_sendaudio_maincard"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        .. Its child

    </android.support.constraint.ConstraintLayout>

</android.support.v7.widget.CardView>

从以下行中删除“+”:

app:layout_constraintTop_toBottomOf="@+id/cardview_sendaudio_info">
而是:

app:layout_constraintTop_toBottomOf="@id/cardview_sendaudio_info"

在创建和命名新视图时添加+号。引用现有视图时不需要它。

可能需要。但是,我删除了所有约束并重新创建了它。它解决了问题,可能是因为你发现了问题。谢谢,这是一个很容易犯的错误,尤其是当你在复制+粘贴的时候