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"/>
如有问题请留言,若转载注明出处。