ConstraintLayout使用

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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值