1、概述
约束布局ConstraintLayout,是Android Studio 2.2中主要的新增功能之一,为了实现自适配
2、引入
app build.gradle中引入
implementation'com.android.support.constraint:constraint-layout:1.1.3'
在布局文件中就可以引入ConstraintLayout使用了
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout/>
3、相对布局属性
最基础的Constraint属性,可以设置在父控件内的位置,相对其他控件的相对位置,
layout_constraintLeft_toLeftOf //同向左对齐
layout_constraintRight_toRightOf //同向右对齐
layout_constraintTop_toTopOf //同向顶对齐
layout_constraintBottom_toBottomOf //同向底对齐
//start=left end=right
layout_constraintRight_toLeftOf //相邻