我总是使用 LinearLayout 和relativelayout,并且我正在阅读有关“新”的内容百分比相对布局 http://developer.android.com/intl/es/reference/android/support/percent/PercentRelativeLayout.html。我有几个问题:
关于 PercentRelativeLayout 的任何其他信息都将受到欢迎。
Thanks!
看着源代码 https://github.com/android/platform_frameworks_support/blob/309059f029f498bf0bf2c431c9f3617915271d7f/percent/src/android/support/percent/PercentRelativeLayout.java,PercentRelativeLayout 基本上是RelativeLayout 的次要扩展。这意味着您需要做出与在RelativeLayout 和LinearLayout 之间进行选择时相同的考虑。
- relativelayout 需要 2 个测量通道 -> 避免将其用作深层视图层次结构的根或嵌套多个relativelayout(更多信息参见这个堆栈溢出 https://stackoverflow.com/questions/4069037/android-is-a-relativelayout-more-expensive-than-a-linearlayout post)
- LinearLayout 中的布局权重也需要 2 次测量 -> 尝试用一个relative/gridlayout 尽可能地替换这些构造(更多信息参见这个堆栈溢出 https://stackoverflow.com/questions/9430764/why-are-nested-weights-bad-for-performance-alternatives post)
最后值得注意的是:
- 除非遇到问题,否则不要优化
- 尽量保持层次结构尽可能扁平
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)