Android linear Layout (linearlayout) Performance related
The beautiful Life of the Sun Vulcan (http://blog.csdn.net/opengl_es)
This article follows "Attribution-non-commercial use-consistent" authoring public agreement
Reprint Please keep this sentence: Sun Vulcan's Beautiful Life-this blog focuses on Agile development and mobile and IoT device research: IOS, Android, HTML5, Arduino, Pcduino , Otherwise, the article from this blog refused to reprint or re-reproduced, thank you for your cooperation.
There are two performance issues in nested linear layouts as follows, can you find them without using Eclipse Adt hints?
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent "Android:paddi ngbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_horizontal_margin" Android: paddingright= "@dimen/activity_horizontal_margin" android:paddingtop= "@dimen/activity_vertical_margin" tools: context= "Com.mitest.linearlayoutexample.MainActivity" > <textview android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= "@string/hello_world"/> <linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:l Ayout_id= "@+id/testlinearlayout02" android:layout_weight= "1" > <textview android:layout_wid Th= "Wrap_content" android:layout_height= "wrap_content"android:layout_weight=" 1 "android:text=" @string/hello_world "/> </linearlayout></li Nearlayout>
Here's the answer:
First place:
Replacing wrap_content with a layout-width value of 0DP will get better performance;
Second place:
The use of nested weights is detrimental to performance.
Linear layout nested a layer of linear layout, and both layers use the weight weight attribute to allocate the layout of the space, if this happens, the interface layout may be considered inappropriate, in my example, the relative layout is a good solution to the problem.
In short, a linear layout that can be replaced with a relative layout, should be a linear layout that can be used to avoid the use of Mian, slightly arbitrary, but will allow a lot of space for future expansion, and every time the interface layout changes, it is best to re-envision the use of various layout methods. Performance is no small matter, especially for Android!
Android linear Layout (linearlayout) Performance related