ConstraintLayout:
(1)导包
compile ‘com.android.support:appcompat-v7:25.0.1’
类名:
android.support.constraint.ConstraintLayout
(2)属性介绍
一、位置控制
子控件的属性:
(1)8个边界约束属性可以固定View的最左边、最右边、最上面、最下面的位置
app:layout_constraintLeft_toLeftOf
app:layout_constraintLeft_toRightOf //我最左边的位置 在别人的右边 下面的意思类似
app:layout_constraintRight_toRightOf
app:layout_constraintRight_toLeftOf app:layout_constraintTop_toTopOf
app:layout_constraintTop_toBottomOf
app:layout_constraintBottom_toBottomOf
app:layout_constraintBottom_toTopOf
(2)通过设置偏移属性,可以控制View在边界范围移动,最左边是0,最右边是1,中间是0.5:
layout_constraintHorizontal_bias(水平方向偏移)(范围0-1)
layout_constraintVertical_bias(垂直方向偏移)(范围0-1)
二、大小控制
layout_constraintHorizontal_weight //水平方向上比重,类似线性布局
layout_constraintVertical_weight //垂直方向上比重,类似线性布局
1.实现水平方向线性布局,所有的View都必须设置左右边界控制属性,而且相互控制
2.实现比重大小控制,必须设置layout_width=”0dp”重点内容
FlexboxLayout
根布局:xmlns:app=”http://schemas.android.com/apk/res-auto”
app:flexDirection=”column”
app:flexWrap=”wrap”
app:justifyContent=”center”
app:alignItems=”flex_start”
app:alignContent=”flex_start”
子元素属性:
app:layout_order="3"
app:layout_flexGrow="1"
app:layout_alignSelf="stretch"
app:layout_flexShrink="1"
app:layout_alignSelf="baseline"
app:layout_flexBasisPercent="80%"