ContrainLayout(部分约束布局属性)

ContrainLayout(部分约束布局属性)

1.app:layout_constraintWidth_percent="0.8" 当View的宽度设置为“0dp” 当前属性有效果 占父控件的%

2.app:layout_constraintHeight_percent="0.8" 当View的高度设置为“0dp” 当前属性有效果 占父控件的%

3.app:layout_constraintTop_toBottomOf="@+id/tv2" 当前View的顶部在id为tv/2的控件的底部

4.app:layout_constraintTop_toTopOf="@+id/tv2" 当前View的顶部和id为tv/2的控件的顶部对齐

5.app:layout_constraintTop_creator=""

6.app:layout_constraintLeft_toRightOf="@+id/tv2" 当前View的左边和id为tv/2的控件的右边对齐

7.app:layout_constraintLeft_toLeftOf="@+id/tv2" 当前View的左边和id为tv/2的控件的左边对齐

8.app:layout_constraintLeft_creator=""

9.app:layout_constraintRight_toLeftOf="@+id/tv2" 当前View的右边和id为tv/2的控件的左边对齐

10.app:layout_constraintRight_toRightOf="@+id/tv2" 当前View的右边和id为tv/2的控件的右边对齐

11.app:layout_constraintRight_creator="@+id/tv2"


常用属性
layout_constraintLeft_toLeftOf                  与目标组件左对齐
layout_constraintLeft_toRightOf              在目标组件的右边
layout_constraintRight_toRightOf              与目标组件右对齐
layout_constraintRight_toLeftOf              在目标组件的左边
layout_constraintTop_toTopOf                  与目标组件上对齐
layout_constraintTop_toBottomOf              在目标组件底部
layout_constraintBottom_toBottomOf              与目标组件下对齐
layout_constraintBottom_toTopOf              在目标组件的上部
layout_constraintBaseline_toBaselineOf          与目标组件基线对齐
layout_constraintStart_toEndOf                RTL
layout_constraintStart_toStartOf            RTL
layout_constraintEnd_toStartOf                RTL
layout_constraintEnd_toEndOf                RTL


当约束目标处在gone状态时的一些属性
layout_goneMarginStart
layout_goneMarginEnd
layout_goneMarginLeft
layout_goneMarginTop
layout_goneMarginRight
layout_goneMarginBottom


内边距
android:paddingTop
android:paddingBottom
android:paddingStart
android:paddingLeft
android:paddingEnd
android:paddingRight

尺寸约束,支持属性:
android:minWidth 设置view最小宽度
android:minHeight 设置view最小高度
android:maxWidth 设置view最大宽度
android:maxHeight 设置view最大高度

Margins 外边距
android:layout_marginTop
android:layout_marginBottom
android:layout_marginStart
android:layout_marginLeft
android:layout_marginEnd
android:layout_marginRight


bias(偏移量)  bias属性可以控制权重
app:layout_constraintVertical_bias="0.9"
app:layout_constraintHorizontal_bias="0.2"


Ratio  该属性还可设置view宽高比,前提宽和高属性至少有一个为0dp
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="1:5"


Percent dimension(百分比布局)


Chain Style(约束链类型)
layout_constraintHorizontal_chainStyle     横向约束链
layout_constraintVertical_chainStyle     纵向约束链
取值 spread,spread_inside和packed


GuideLine
Guideline是只能用在ConstraintLayout布局里面的一个工具类,用于辅助布局,类似为辅助线,可以设置android:orientation属性来确定是横向的还是纵向的。

layout_constraintGuide_begin,指定左侧或顶部的固定距离,如100dp,在距离左侧或者顶部100dp的位置会出现一条辅助线
layout_constraintGuide_end,指定右侧或底部的固定距离,如30dp,在距离右侧或底部30dp的位置会出现一条辅助线
layout_constraintGuide_percent,指定在父控件中的宽度或高度的百分比,如0.8,表示距离顶部或者左侧的80%的距离。


Barrier 以这些组件的某一侧为基准
app:constraint_referenced_ids=""
app:barrierDirection="right"


Group
Group的作用感觉比较鸡肋,通过app:constraint_referenced_ids添加对子View的引用,然后统一的显示或者隐藏控件。这里不再赘述。

你可能感兴趣的:(ContrainLayout(部分约束布局属性))