android 约束布局总结(ConstraintLayout)

本文章供个人学习查看,如果学习直接去大佬链接:文章链接

ConstraintLayout动画使用的两种方式:代码中:链接,布局中:链接

认识:约束布局可以减少布局的嵌套,提高性能

属性:

1:相对位置:

layout_constraintLeft_toLeftOf
layout_constraintLeft_toRightOf
layout_constraintRight_toLeftOf
layout_constraintRight_toRightOf
layout_constraintTop_toTopOf
layout_constraintTop_toBottomOf
layout_constraintBottom_toTopOf
layout_constraintBottom_toBottomOf
// start与end和left与right基本一样
layout_constraintStart_toEndOf
layout_constraintStart_toStartOf
layout_constraintEnd_toStartOf
layout_constraintEnd_toEndOf

2:设置相对位置的比例(设置“拉力”的大小)

layout_constraintHorizontal_bias
layout_constraintVertical_bias

3:设置权重weight(需要设置宽或高为0dp)

app:layout_constraintHorizontal_weight
app:layout_constraintVertical_weight

4:设置 view链的排列样式(设置在头view控件中)

layout_constraintHorizontal_chainStyle
layout_constraintVertical_chainStyle
例:
android 约束布局总结(ConstraintLayout)_第1张图片

5:文本内容对齐:

layout_constraintBaseline_toBaselineOf

6:设置辅助线

使用Guideline 控件
1:android:orientation取值为”vertical”和”horizontal” 决定:辅助线的横向纵向

2:下列三个属性:决定了辅助线的位置
layout_constraintGuide_begin
layout_constraintGuide_end
layout_constraintGuide_percent(此百分比是当前辅助线所在的ConstraintLayout父布局的百分比

7:通用属性:

android:layout_marginStart
android:layout_marginEnd
android:layout_marginLeft
android:layout_marginTop
android:layout_marginRight
android:layout_marginBottom

8:设置宽高比:

app:layout_constraintDimensionRatio=“16:6”
app:layout_constraintDimensionRatio=“H,16:6”
app:layout_constraintDimensionRatio=“W,16:6”

你可能感兴趣的:(加深学习)