LINEAR LAYOUT ::
- 在线性布局中,顾名思义,所有元素都是
以线性方式显示
- 水平或垂直,此行为设置为
android:orientation 这是节点的一个属性
线性布局。
- 线性布局将每个子元素一个接一个地排成一行,
水平或垂直。
单击此处 ---- 查看线性布局的 Android 文档参考
RELATIVE LAYOUT::
- 在相对布局中,每个元素都相对于其他元素自行排列
元素或父元素。
- 在逐个添加视图等时很有帮助
- 使用相对布局,您可以为每个子元素提供一个 LayoutParam
准确指定相对于父级或父级应该去的位置
相对于其他孩子。
- 视图在相对布局中彼此分层
单击此处 ---- 查看 ---Android 文档参考相对布局
优化::看一下优化布局层次结构
观看次数越少越好::
The number one goal for your layouts should be using the fewest number of Views possible. The fewer Views you have to work with, the faster your application will run. Excessive nesting of Views further slows down your application.
A RelativeLayout hierarchy will typically use fewer Views and have a flatter tree than a LinearLayout hierarchy. With LinearLayout, you must create a new LinearLayout every time you want to change the orientation of your views – creating additional Views and a more nested hierarchy. As a result, it is recommended that you first use RelativeLayout for any layout that has any complexity. There is a high probability you will reduce the number of Views – and the depth of your View tree – by doing so.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)