According to your layout, I've just updated your layout added colour to see the view, below is the layout and image.
Here is your layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout android:id="@+id/coordinatorLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/view"
android:layout_width="100dp"
android:layout_height="720dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@color/black_2"/>
<Button
android:id="@+id/toggleBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="72dp"
android:text="this is button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="120dp"
android:text="this is text view"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="@+id/toggleBtn"
app:layout_constraintStart_toStartOf="@+id/toggleBtn"
app:layout_constraintTop_toBottomOf="@+id/toggleBtn" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Image with view
So, if you have view, because of the height of ConstraintLayout
is 720dp the ConstraintLayout will stretch to maximum because of wrap_content behaviour.
Height of Constraint Layout with View
And if you remove view, then the height of ConstraintLayout also changes
Height of Constraint Layout without View
It depends on your requirement, you need to have View or not, but
currently it has no impact.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…