android - 最好的 LinearLayout、RelativeLayout 和最新的 ConstraintLayout
问题描述
我对此有很多疑问。我很擅长使用 LinearLayout、RelativeLayout 或 ConstraintLayout,想知道最好的。如果有些人有理由使用其中之一。
一些问题:
- 我认为 LinearLayout 会添加一个节点层次结构,这将比 RelativeLayout 或 ContraintLayout 花费更多的时间来渲染,对吗?
- 为什么 android 正在考虑
ContraintLayout
使用 more thanRelativeLayout
andLinearLayout
?即使我可以在LinearLayout
或RelativeLayout
解决方案
我认为 LinearLayout 会添加一个节点层次结构,这将比 RelativeLayout 或 ContraintLayout 花费更多的时间来渲染,对吗?
嵌套LinearLayout
小部件的渲染速度可能会更慢。不能保证渲染速度会变慢。使用嵌套权重是获得一组慢速嵌套LinearLayout
小部件的一种已知方法。
为什么android正在考虑使用ContraintLayout而不是RelativeLayout和LinearLayout?
ConstraintLayout
处理比 doLinearLayout
和更多的场景RelativeLayout
。ConstraintLayout
IDE 比 is 更容易通过拖放支持RelativeLayout
。
即使我可以在 LinearLayout 或 RelativeLayout 中进行相同的布局
LinearLayout
有多种场景在or中难以实现RelativeLayout
,但ConstraintLayout
可以轻松处理,例如:
圆形定位
自身的最小和最大尺寸
ConstraintLayout
(帮助wrap_content
避免变得太小或太大)让孩子保持特定的纵横比
实现一些种类的链
将儿童锚定到基于规则的人工线路,例如
Guideline
和Barrier
推荐阅读
- python-3.x - 一个excel表格列表,我如何组合成一个单行字符串
- firebase - 如何解决它“RangeError(索引):无效值:有效值范围为空:0”在颤动中?
- c++ - 如何通过程序添加到 QAT 。程序使用c++、mfc mdi
- javascript - Laravel 和 Vuetify 未知的自定义元素
- sqlite - 加快 SQLite 中的 COUNT DISTINCT 查询
- http - 如何使用 Wireshark 访问网站?
- java - android java从内部类访问,需要声明final
- python - 从单个 Txt 文件创建多个音频文件
- java - 使用 Java 高级 REST 客户端的 ElasticSearch 多词查询
- python - 熊猫数据框查询未找到价值