<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
xmlns:tools="http://schemas.android.com/tools";
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto";
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFB6C1"
android:layout_weight="2">
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto";
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#483D8B"
android:layout_weight="1">
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto";
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#40E0D0"
android:layout_weight="1">
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
约束布局ConstraintLayout看这一篇就够了目录 1.介绍 2.为什么要用ConstraintLayout 3.如何使用ConstraintLayout3.1 添加依赖3.2 相对定位3.3 角度定位3.4 边距3.5...