展会信息港展会大全

Android 深入研究layout优化
来源:互联网   发布日期:2015-10-13 15:15:08   浏览:2012次  

导读:Android layout 的优化直接关系着程序是否快速运转,一下是开发过程中的几点建议:1.尽量不要使用linelayout,使用relativelayout替换。android:lay...

Android layout 的优化直接关系着程序是否快速运转,一下是开发过程中的几点建议:

1.尽量不要使用linelayout,使用relativelayout替换。android:layout_alignWithParentIfMissing只对relativelayout有用,如果那个视图设置为gone,这个属性将按照父视图进行调整。

2.对于使用adapter的控件,如list,使用递归太深的布局,会严重影响性能。

3.对于textview和imageview组成的layout,直接使用textview替换(drawableTop类似属性)。

4.对于父layout是FrameLayout的,如果子layout也是FrameLayout,可以将FrameLayout替换为merge,这样可以减少一层递归深度。

android:layout_width="fill_parent"

android:layout_height="fill_parent"/>

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:gravity="center"

android:visibility="gone"/>

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/softname"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginBottom="10dip"

android:layout_gravity="center"

android:gravity="center"

android:drawableTop="@drawable/icon"/>

如有问题请留言,若转载注明出处。

赞助本站

人工智能实验室

相关热词: android开发

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港