全网整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:400-708-3566

Android新布局方式ConstraintLayout快速入门教程

前言

在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四种常见布局方式示例教程  # 拖动  # 其实很简单  # 很好  # 是指  # 不是很  # 这句话  # 用了  # 没了  # 要对  # 你已经  # 这篇文章  # 会用  # 谢谢大家  # 不知道为什么  # 试着  # 到此  # 拖着  # 用得  # 来写  # 上以 


相关文章: 孙琪峥织梦建站教程如何优化数据库安全?  c++怎么用jemalloc c++替换默认内存分配器【性能】  c++23 std::expected怎么用 c++优雅处理函数错误返回【详解】  如何在云主机快速搭建网站站点?  建站之星如何配置系统实现高效建站?  网站制作公司广州有几家,广州尚艺美发学校网站是多少?  建站之星导航菜单设置与功能模块配置全攻略  如何在搬瓦工VPS快速搭建网站?  如何在香港免费服务器上快速搭建网站?  建站主机无法访问?如何排查域名与服务器问题  黑客入侵网站服务器的常见手法有哪些?  如何在建站之星绑定自定义域名?  建站之星×万网:智能建站系统+自助建站平台一键生成  长沙做网站要多少钱,长沙国安网络怎么样?  如何选择可靠的免备案建站服务器?  如何在沈阳梯子盘古建站优化SEO排名与功能模块?  相亲简历制作网站推荐大全,新相亲大会主持人小萍萍资料?  如何快速生成高效建站系统源代码?  如何在局域网内绑定自建网站域名?  SAX解析器是什么,它与DOM在处理大型XML文件时有何不同?  宿州网站制作公司兴策,安徽省低保查询网站?  广平建站公司哪家专业可靠?如何选择?  高端网站建设与定制开发一站式解决方案 中企动力  青岛网站设计制作公司,查询青岛招聘信息的网站有哪些?  如何通过多用户协作模板快速搭建高效企业网站?  电视网站制作tvbox接口,云海电视怎样自定义添加电视源?  小自动建站系统:AI智能生成+拖拽模板,多端适配一键搭建  制作网站软件推荐手机版,如何制作属于自己的手机网站app应用?  如何快速重置建站主机并恢复默认配置?  Swift中switch语句区间和元组模式匹配  简历在线制作网站免费版,如何创建个人简历?  制作充值网站的软件,做人力招聘为什么要自己交端口钱?  一键制作网站软件下载安装,一键自动采集网页文档制作步骤?  免费网站制作appp,免费制作app哪个平台好?  建站之星3.0如何解决常见操作问题?  整人网站在线制作软件,整蛊网站退不出去必须要打我是白痴才能出去?  php json中文编码为null的解决办法  如何快速搭建安全的FTP站点?  建站之星如何修改网站生成路径?  如何快速配置高效服务器建站软件?  如何在IIS7中新建站点?详细步骤解析  制作网站的软件下载免费,今日头条开宝箱老是需要下载怎么回事?  如何在景安服务器上快速搭建个人网站?  建站主机与虚拟主机有何区别?如何选择最优方案?  实惠建站价格推荐:2025年高性价比自助建站套餐解析  模具网站制作流程,如何找模具客户?  宁波免费建站如何选择可靠模板与平台?  如何快速辨别茅台真假?关键步骤解析  如何在Windows环境下新建FTP站点并设置权限?  设计网站制作公司有哪些,制作网页教程? 

您的项目需求

*请认真填写需求信息,我们会在24小时内与您取得联系。