Android ConstraintLayout

Android ConstraintLayout详解

AndroidStudio2.2开始,就推出了一个牛逼的布局,ConstraintLayout,此布局像是一个升级版的RelativeLayout,但是功能比RelativeLayout强大许多,号称一层

布局就可以搞定复杂页面。在AS2.2下还可以用拖拽控件的方式就行布局(设计师的福音),不过本篇不讲解拖拽控件的相关用法,主要讲解一些相关属性含义。 


开始!

相对位置

这个相对位置的设置有点类似RelativeLayout的layout_toLeftOf、alignParentLeft等这些属性。 

下面是本人对此属性的总结:

layout_constraint[本源位置]_[目标位置]="[目标ID]"

ConstraintLayout一共支持相对位置的属性在此: 

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

拿第一个属性来说,layout_constraintLeft_toLeftOf=”@+id/id_first”,表示当前View的左边界与id_first的View的做边界对齐。其实这个属性翻译成中文就是:当前view的左边对齐与引用view的左边。 

例子:

你可能感兴趣的:(Android ConstraintLayout)