其中为了嵌套布局是最有效的安卓 [英] Which order of nested layouts is most efficient in Android
问题描述
我不认为我真的永远比约三个层次值得布局(<$ C C $> RelativeLayout的,的LinearLayout
,的FrameLayout
)的Android系统。我没有想过列表中的项目还使用自定义布局的ListView
,但只是正常布局的活动。
I don't think I have really ever nested more than about three levels worth of Layouts (RelativeLayout
, LinearLayout
, FrameLayout
) in Android. I am not thinking about list items which also use a custom layout for ListView
but just normal layouts for an activity.
要的一点,虽然,我是聊天约嵌套布局另一个开发有一定的布局,我们在讨论,他似乎认为,即使是一些嵌套布局真的放缓的表现。我想有一定的道理,但不能是那么多。
To the point though, I was chatting with another developer about nesting layouts for a certain layout we were discussing and he seemed to think that even a few nested layouts really slowed down performance. I figured there is some truth but it cant be that much.
有没有人有一个更专业的方式呢?任何输入?意见?
Does anyone have a more expert approach to this? Any input? Opinion?
感谢。
更新那些谁发现在谷歌: 下面的第一个答案是一个很好的资源。它看起来像一个不少,人们似乎跳过这样的答案,但请检查出来。非常有价值的。
UPDATE for those who found on Google: The first answer below is a great resource. It looks like a lot and people seem to skip over answers like that but please check it out. Very valuable.
推荐答案
我想有没有灵丹妙药,但我会给你一些提示:
I guess there is no silver bullet for this but I will give you some tips:
1)尝试使用提供了Android SDK的工具。
我倾向于来分析我的布局与 hierarchyviewer
和 layoutopt
试图减少量查看
使用与树的高度。
I tend to analyze my layouts with hierarchyviewer
and layoutopt
trying to reduce the amount of View
used and the height of the tree.
2)的阅读罗曼盖伊帖子关于&LT;包括&GT;
,&LT;合并&GT;
和&LT; ViewStub&GT;
这种标签是不经常使用,但它们提供极快的速度黑客。
2) Read Romain Guy's posts about <include>
, <merge>
and <ViewStub>
This tags are not used often but they provide great speed "hacks".
- <一个href="http://www.curious-creature.org/2009/03/01/android-layout-tricks-3-optimize-part-1/">http://www.curious-creature.org/2009/03/01/android-layout-tricks-3-optimize-part-1/
- <一个href="http://www.curious-creature.org/2009/03/16/android-layout-tricks-4-optimize-part-2/">http://www.curious-creature.org/2009/03/16/android-layout-tricks-4-optimize-part-2/
- http://www.curious-creature.org/2009/03/01/android-layout-tricks-3-optimize-part-1/
- http://www.curious-creature.org/2009/03/16/android-layout-tricks-4-optimize-part-2/
3)使用 dmtracedump
和MESURE多久没有考虑到膨胀的景色。
3) Use dmtracedump
and mesure how long does it take to inflate a view.
您可以检查需要多长时间膨胀的视图。得到一个充气机和MESURE它需要多长时间来夸大你的每一个选择。
You can check how long it takes to inflate a view. Get an inflator and mesure how long it takes to inflate each of your options.
这篇关于其中为了嵌套布局是最有效的安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!