Chr*_*rry 209 android listview android-lint
我只是在xml中构建一些UI,Lint给了我一个警告,并说要将android:baselineAligned设置为false以提高ListView的性能.
添加此警告的Lint更改的文档说
布局性能:使用权重查找LinearLayouts,您应该设置android:baselineAligned ="false"以获得更好的性能,还会发现嵌套权重可能导致性能问题的情况.
有人可以解释为什么这会改善性能,特别是涉及体重时?
Nim*_*a G 159
通过设置android:baselineAligned="false",您可以阻止应用程序布局必须执行的额外工作,以便对齐其子级的基线; 这显然可以提高性能.(UI上不必要的操作=>更好的性能)
Xar*_*mer 19
怎么android:baselineAligned="false" 帮忙 它可能不是答案,但有助于获得概念.
我刚刚设法在水平LinearLayout中垂直居中3个项目(图标,文本,按钮).
这可能看起来很简单,但实际上指定android:gravity ="center_vertical"作为LinearLayout属性是不够的 - 图标居中,但文本和按钮不是.这是因为(推测)文本具有基线,并且居中算法使用它而不是"真实"垂直中心.但更糟糕的是 - 按钮(文本旁边)使用文本的基线居中!
在LinearLayout中指定android:baselineAligned ="false"会将其关闭,并且所有内容都正确对齐.
boi*_*ter 14
// Baseline alignment requires to measure widgets to obtain the
// baseline offset (in particular for TextViews). The following
// defeats the optimization mentioned above. Allow the child to
// use as much space as it wants because we can shrink things
// later (and re-measure).
if (baselineAligned) {
final int freeSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
child.measure(freeSpec, freeSpec);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
44173 次 |
| 最近记录: |