ConstraintLayout使用
//设置margin属性时,如果针对没有约束的边进行margin属性设置是无效的
ConstraintLayout
//基于baseline对齐
app:layout_constraintBaseline_toBaselineOf=""
//偏移属性,范围0-1
app:layout_constraintHorizontal_bias="0.39"
//针对设置的约束的布局不可见时,goneMargin属性起作用,会对当前布局起到margin作用
app:layout_goneMarginLeft="100dp"
//将组建之间互相约束,两个边之间互相约束,出现这个属性
//使用这个属性,需要按住ctrl,鼠标选中多个组建,前提是选中组建没有约束的情况下,
//然后右键chains选项
//此属性可以将ConstraintLayout当成线性布局使用
app:layout_constraintHorizontal_chainStyle="packed" //贴到一起
app:layout_constraintHorizontal_chainStyle="spread" //位置等分
app:layout_constraintHorizontal_chainStyle="spread_inside" //两边贴边
//约束布局当线性布局使用weight属性
//环形布局,以下是在子布局中实现的属性
app:layout_constraintCircleAngle="30" //设置当前控件的角度
app:layout_constraintCircleRadius="30dp" //设置当前控件的半径
app:layout_constraintCircle="@id/tv_round" //设置以哪个控件为圆心
//约束布局当表格布局使用Flow
<androidx.constraintlayout.helper.widget.Flow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
app:flow_wrapMode="chain"
app:constraint_referenced_ids="tv_1,tv_2,tv_3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
//layer可以统一做动画效果
Guideline 切换语言的时候,会被屏幕覆盖
Barrier (多语言)切换语言如果过长,则不会被覆盖,自动改变位置
barrierDirection = "end"
constraint_referenced_ids = "跟id"
Placeholder
ConstraintHelper的使用2.0中自定义辅助控件
相关连接
https://developer.android.google.cn/training/constraint-layout/