Android ConstraintLayout 约束布局 1,flutter底部弹窗

android:layout_height=“wrap_content”
android:text=“拉伸我要被要被拉伸我要被拉伸”
android:textSize=“20sp”
app:layout_constraintWidth_default=“wrap”
app:layout_constraintStart_toEndOf="@id/viewA"
app:layout_constraintEnd_toStartOf="@id/viewB"
app:layout_constraintTop_toTopOf=“parent”
/>

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RmsPLx7r-1638154247345)(https://user-gold-cdn.xitu.io/2019/11/14/16e69c175b8e3534?imageView2/0/w/1280/h/960/ignore-error/1)]

当指定为wrap模式,则会保留约束条件:


android:layout_width=“0dp”
app:layout_constraintWidth_default=“wrap”

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1zbx0bwi-1638154247371)(https://user-gold-cdn.xitu.io/2019/11/14/16e69c35ea94d831?imageView2/0/w/1280/h/960/ignore-error/1)]

另外,针对传统的WRAP_CONTENT模式,约束布局有额外的属性,使得它也能保留约束条件:app:layout_constrainedWidth="true"此时与wrap模式一样的效果。

3.1.3 percent模式

app:layout_constraintWidth_default="percent":以父布局的百分比作为自身的大小,即百分比布局。(利用次特性可解决部分常见适配),通过app:layout_constraintWidth_percent设置比例大小,0f-1.0f


android:layout_width=“0dp”
app:layout_constraintWidth_default=“percent”
app:layout_constraintWidth_percent=“0.8”

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RgmJbRa8-1638154247372)(https://user-gold-cdn.xitu.io/2019/11/14/16e69ca990d05117?imageView2/0/w/1280/h/960/ignore-error/1)]

3.1.4 指定宽高比(ratio)

app:layout_constraintDimensionRatio:约束布局还可以指定view自身宽高比例。

其值可以为“width:height”或者“width/height”,如宽是高的2倍:app:layout_constraintDimensionRatio="2:1"app:layout_constraintDimensionRatio="2"

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值