将基线对齐设置为 false 如何提高 LinearLayout 的性能?
我刚刚在 xml 中构建一些 UI,Lint 给了我一个警告,并说将 android:baselineAligned 设置为 false 以提高 ListView 的性能。
添加此警告的 Lint 更改的文档说
布局性能:在您应该的位置找到具有权重的 LinearLayouts 设置 android:baselineAligned="false" 以获得更好的性能,并且 查找可能会影响性能的嵌套权重的情况 问题。
有人可以解释为什么这可以提高表现,特别是在涉及重量时?
I was just building some UI in xml, and Lint gave me a warning and said to set android:baselineAligned to false to improve performance in ListView.
The docs for the Lint changes that added this warning say
Layout performance: Finds LinearLayouts with weights where you should
set android:baselineAligned="false" for better performance, and also
finds cases where you have nested weights which can cause performance
problems.
Can somebody explain why this improves performance, specifically when weight is involved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过设置
android:baselineAligned="false"
,您可以防止应用布局为了对齐其子级基线而必须执行的额外工作;这可以明显提高性能。 (减少UI上不必要的操作=>更好的性能)By setting
android:baselineAligned="false"
, you're preventing the extra work your app's layout has to do in order to Align its children's baselines; which can obviously increase the performance. (Fewer unnecessary operations on UI => Better performance)android:baselineAligned="false"
如何提供帮助。它可能不是答案,但有助于获得概念。how
android:baselineAligned="false"
help . It may not be the answer but help to get concept.https://github.com/android /platform_frameworks_base/blob/master/core/java/android/widget/LinearLayout.java#L1093
https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/LinearLayout.java#L1093