Android新布局方式ConstraintLayout快速入门教程
发布时间 - 2026-01-11 01:22:47 点击率:次前言

在Android开发中,我们通常是手写布局,很少会用拖动来写布局,虽然ConstraintLayout在I/O上以拖动来展现了各种功能,我估计在以后开发中,程序员还是习惯手撸代码。
我自己试着拖着用了一下,用得不是很明白 ,而且用起来效果不是很好。
那么
直接上手撸了一下~~~
其实很简单
Button1:app:layout_constraintBottom_toTopOf="@id/iv_head"
我们把这个属性拆开来看,constraintBottom指的本身的底部,即Button1的顶部,toTopOf是指ImageView的顶部,那么这句话的意思就是
Aligns the bottom of the desired view to the top of another.(官方原文)
翻译一下就是Button1的底部要和ImageView的顶部对齐
Button1 app:layout_constraintRight_toLeftOf="@id/iv_head"
根据上面的规则我们就知道Button1的右边要和ImageView的左边对齐。
其实很简单就是说两个View的某个方位要对齐
没了,就这么简单,其它属性可以举一反三,它比RelativeLayout控制起来更加得以就手。
- layout_constraintTop_toTopOf — Align the top of the desired view to the top of another.
- layout_constraintTop_toBottomOf — Align the top of the desired view to the bottom of another.
- layout_constraintBottom_toTopOf — Align the bottom of the desired view to the top of another.
- layout_constraintBottom_toBottomOf — Align the bottom of the desired view to the bottom of another.
- layout_constraintLeft_toTopOf — Align the left of the desired view to the top of another.
- layout_constraintLeft_toBottomOf — Align the left of the desired view to the bottom of another.
- layout_constraintLeft_toLeftOf — Align the left of the desired view to the left of another.
- layout_constraintLeft_toRightOf — Align the left of the desired view to the right of another.
- layout_constraintRight_toTopOf — Align the right of the desired view to the top of another.
- layout_constraintRight_toBottomOf — Align the right of the desired view to the bottom of another.
- layout_constraintRight_toLeftOf — Align the right of the desired view to the left of another.
- layout_constraintRight_toRightOf — Align the right of the desired view to the right of another.
- If desired, attributes supporting start and end are also available in place of left and right alignment.
到此,你已经掌握了一大半的ConstraintLayout知识点
还有其它的一些属性
app:layout_constraintStart_toEndOf
意思就是Button的开始部分(从左往右看,开始部分就是Button的左边)与ImageView的右边是对齐的。
app:layout_constraintStart_toStartOf
这个就是说Button的左边与ImageView的左边是对齐的
不知道为什么上面已经出的属性能够满足布局需要了,为什么还要再出start和end的。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对的支持。
# constraintlayout布局
# constraintlayout用法
# constraintlayout属性
# Android 开发之旅:详解view的几种布局方式及实践
# Android实现Tab布局的4种方式(Fragment+TabPageIndicator+View
# Android 五大布局方式详解
# Android开发之基本控件和四种布局方式详解
# 分享五种Android常用布局方式
# Android四种常见布局方式示例教程
# 拖动
# 其实很简单
# 很好
# 是指
# 不是很
# 这句话
# 用了
# 没了
# 要对
# 你已经
# 这篇文章
# 会用
# 谢谢大家
# 不知道为什么
# 试着
# 到此
# 拖着
# 用得
# 来写
# 上以
相关栏目:
【
网站优化151355 】
【
网络推广146373 】
【
网络技术251813 】
【
AI营销90571 】
相关推荐:
如何在IIS中配置站点IP、端口及主机头?
如何破解联通资金短缺导致的基站建设难题?
专业企业网站设计制作公司,如何理解商贸企业的统一配送和分销网络建设?
iOS发送验证码倒计时应用
Laravel如何配置和使用队列处理异步任务_Laravel队列驱动与任务分发实例
java ZXing生成二维码及条码实例分享
如何在IIS7中新建站点?详细步骤解析
进行网站优化必须要坚持的四大原则
Laravel N+1查询问题如何解决_Eloquent预加载(Eager Loading)优化数据库查询
Laravel如何使用Vite进行前端资源打包?(配置示例)
惠州网站建设制作推广,惠州市华视达文化传媒有限公司怎么样?
如何快速生成ASP一键建站模板并优化安全性?
如何快速搭建支持数据库操作的智能建站平台?
Laravel distinct去重查询_Laravel Eloquent去重方法
利用JavaScript实现拖拽改变元素大小
三星网站视频制作教程下载,三星w23网页如何全屏?
利用 Google AI 进行 YouTube 视频 SEO 描述优化
*服务器网站为何频现安全漏洞?
如何为不同团队 ID 动态生成多个“认领值班”按钮
Laravel DB事务怎么使用_Laravel数据库事务回滚操作
智能起名网站制作软件有哪些,制作logo的软件?
Laravel怎么进行数据库事务处理_Laravel DB Facade事务操作确保数据一致性
长沙做网站要多少钱,长沙国安网络怎么样?
如何做网站制作流程,*游戏网站怎么搭建?
PHP正则匹配日期和时间(时间戳转换)的实例代码
微信小程序 配置文件详细介绍
🚀拖拽式CMS建站能否实现高效与个性化并存?
北京网站制作公司哪家好一点,北京租房网站有哪些?
Laravel怎么配置不同环境的数据库_Laravel本地测试与生产环境动态切换【方法】
如何在建站主机中优化服务器配置?
Laravel如何实现多级无限分类_Laravel递归模型关联与树状数据输出【方法】
在Oracle关闭情况下如何修改spfile的参数
Laravel如何为API编写文档_Laravel API文档生成与维护方法
Laravel怎么配置S3云存储驱动_Laravel集成阿里云OSS或AWS S3存储桶【教程】
专业型网站制作公司有哪些,我设计专业的,谁给推荐几个设计师兼职类的网站?
如何在建站宝盒中设置产品搜索功能?
EditPlus 正则表达式 实战(3)
如何在Windows虚拟主机上快速搭建网站?
Python文件异常处理策略_健壮性说明【指导】
JS中使用new Date(str)创建时间对象不兼容firefox和ie的解决方法(两种)
如何用搬瓦工VPS快速搭建个人网站?
Laravel如何获取当前用户信息_Laravel Auth门面获取用户ID
矢量图网站制作软件,用千图网的一张矢量图做公司app首页,该网站并未说明版权等问题,这样做算不算侵权?应该如何解决?
胶州企业网站制作公司,青岛石头网络科技有限公司怎么样?
使用Dockerfile构建java web环境
香港服务器建站指南:外贸独立站搭建与跨境电商配置流程
详解Huffman编码算法之Java实现
Laravel怎么实现模型属性转换Casting_Laravel自动将JSON字段转为数组【技巧】
如何快速搭建FTP站点实现文件共享?
如何在云主机上快速搭建网站?

