- "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">
-
- <TextView
- android:id="@+id/tv1"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:background="@android:color/holo_red_light"
- android:gravity="center"
- android:text="1"
- android:textSize="100dp"
- app:layout_constraintHorizontal_weight="1"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintRight_toLeftOf="@id/tv2"
- app:layout_constraintTop_toTopOf="parent" />
-
- <TextView
- android:id="@+id/tv2"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:background="@android:color/holo_green_light"
- android:gravity="center"
- android:text="2"
- android:textSize="100dp"
- app:layout_constraintHorizontal_weight="1"
- app:layout_constraintLeft_toRightOf="@id/tv1"
- app:layout_constraintRight_toLeftOf="@id/tv3"
- app:layout_constraintTop_toTopOf="parent" />
-
- <TextView
- android:id="@+id/tv3"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:background="@android:color/holo_blue_light"
- android:gravity="center"
- android:text="3"
- android:textSize="100dp"
- app:layout_constraintHorizontal_weight="1"
- app:layout_constraintLeft_toRightOf="@id/tv2"
- app:layout_constraintRight_toRightOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
-
- androidx.constraintlayout.widget.ConstraintLayout>

Android约束布局ConstraintLayout-CSDN博客https://blog.csdn.net/zhangphil/article/details/78217322