代码如下,基本上就是利用space
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/id_constraint_layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
>
<ImageView
android:id="@+id/id_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher_round"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
<Space
android:id="@+id/id_space"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="60dp"
android:background="@color/colorAccent"
app:layout_constraintBottom_toBottomOf="@id/id_image"
app:layout_constraintEnd_toEndOf="@id/id_image"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小欢喜呀呀呀呀呀"
android:textColor="#ffffff"
android:background="@color/colorAccent"
app:layout_constraintTop_toBottomOf="@id/id_space"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/id_constraint_layout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/id_constraint_layout1"
>
<Space
android:id="@+id/id_space_margin_right"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginRight="50dp"
app:layout_constraintRight_toRightOf="@id/id_image2"
app:layout_constraintTop_toTopOf="@id/id_image2"
/>
<TextView
android:layout_width="100dp"
android:layout_height="50dp"
android:background="@color/colorAccent"
android:text="嘿嘿嘿--哈哈哈"
android:textColor="#ffffff"
android:textSize="20dp"
android:gravity="center"
app:layout_constraintRight_toLeftOf="@id/id_space_margin_right"
app:layout_constraintTop_toTopOf="@id/id_image2"
app:layout_constraintBottom_toBottomOf="@id/id_image2"
/>
<ImageView
android:id="@+id/id_image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher_round"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
app:layout_constraintTop_toBottomOf="@id/id_constraint_layout2"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
>
<Space
android:id="@+id/id_space_margin_left"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="50dp"
app:layout_constraintLeft_toLeftOf="@id/id_image3"
app:layout_constraintTop_toTopOf="@id/id_image3"
/>
<TextView
android:layout_width="100dp"
android:layout_height="50dp"
android:background="@color/colorAccent"
android:text="嘿嘿嘿--哈哈哈"
android:textColor="#ffffff"
android:textSize="20dp"
android:gravity="center"
app:layout_constraintLeft_toRightOf="@id/id_space_margin_left"
app:layout_constraintTop_toTopOf="@id/id_image3"
app:layout_constraintBottom_toBottomOf="@id/id_image3"
/>
<ImageView
android:id="@+id/id_image3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher_round"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
完事