参考资料: http://blog.csdn.net/guolin_blog/article/details/53122387html
https://developer.android.google.cn/reference/android/support/constraint/ConstraintLayout.htmlandroid
1、constraintlayout简介app
ConstraintLayout是Android Studio 2.2中主要的新增功能之一,也是Google在去年的I/O大会上重点宣传的一个功能。在传统的Android开发当中,界面基本都是靠编写XML代码完成的。虽然Android Studio也支持可视化的方式来编写界面,可是操做起来并不方便。ConstraintLayout就是为了解决这一现状而出现的,能够方便的进行可视化的编写界面。ide
ConstraintLayout还有一个优势,它能够有效地解决布局嵌套过多的问题。ConstraintLayout则是使用约束的方式,来指定各个控件的位置和关系的。它有点相似于RelativeLayout,但远比RelativeLayout要更强大。布局
2、约束类型ui
2.1如下是目前能使用的约束类型:this
##Relative positioning
如下是相对约束的类型: layout_constraintLeft_toLeftOf layout_constraintLeft_toRightOf layout_constraintRight_toLeftOf layout_constraintRight_toRightOf layout_constraintTop_toTopOf layout_constraintTop_toBottomOf layout_constraintBottom_toTopOf layout_constraintBottom_toBottomOf layout_constraintBaseline_toBaselineOf layout_constraintStart_toEndOf layout_constraintStart_toStartOf layout_constraintEnd_toStartOf layout_constraintEnd_toEndOf
##Margins:
The usual layout margin attributes can be used to this effect: android:layout_marginStart android:layout_marginEnd android:layout_marginLeft android:layout_marginTop android:layout_marginRight android:layout_marginBottom Note that a margin can only be positive or equals to zero, and takes a Dimension.
##center position
layout_constraintHorizontal_bias
layout_constraintVertical_bias
<android.support.constraint.ConstraintLayout ...>
<Button android:id="@+id/button" ... app:layout_constraintHorizontal_bias="0.3" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent/>
</>
2.2常见操做google
##创建项目:添加constraintlayout依赖 implementation 'com.android.support.constraint:constraint-layout:1.0.2'
##other layout convert to constraintlayoutspa
##删除约束方法
下图中,1为单个约束删除,2为删除单个组件的全部约束,3为删除全部组件的全部约束
##改变组件的宽度和高度的模式.net
位于Inspector最中间的那个正方形区域,它是用来控制控件大小的。一共有三种模式可选,每种模式都使用了一种不一样的符号表示,点击符号便可进行切换。


表示wrap content,这个咱们很熟悉了,不须要进行什么解释。

表示固定值,也就是给控件指定了一个固定的长度或者宽度值。

表示any size,它有点相似于match parent,但和match parent并不同,是属于ConstraintLayout中特有的一种大小控制方式,下面咱们来重点讲解一下。
3、guideline
虚拟组件,辅助页面布局。
##guideline
4、自动添加约束
autoconnect
infer Constraints