Android: layout, rendering, memory leakage, response speed, listview and bitmap, thread optimization, and some optimization suggestions !, Androidlistview
1. Layout Optimization
First, Remove useless controls and layers in the layout, and then selectively use viewgroups with lower performance. For example, if RelativeLayout and LinearLayout can be used in the layout, we will use LinearLayout, because the functions of RelativeLayout are complex, the layout of RelativeLayout is costly.
Elegant CPU usage.
Another method of layout optimization is to use the <include>, <merge>, and <viewstub> labels. <Include> is mainly used for layout reuse. <include> and <merge> labels can be used together to reduce the layout hierarchy. <viewstub> ze provides the On-Demand Loading Function, yes
The layout in <viewstub> is loaded to the memory. This improves the initialization efficiency of the program. The following describes how to use them.
<Include>: Add <include layout = "@ layout/main_portals"/> in your root layout. Then, in the main_portals layout
<Merge xmlns: android = "http://schemas.android.com/apk/res/android"
Xmlns: hyhotel = "http://schemas.android.com/apk/res/com.hysmarthotel.movie">
// Add view as needed
</Merge>
Note: <include> labels only support attributes starting with android: layout. For example, android: layout_width and android: layout_height are not supported. For example, android: background and android: id are special cases, if this attribute is specified, the included layout is also specified
The ID. If the attribute android: layout _ * is specified, android: layout_width and android: layout_height must exist. Otherwise, other android: layout _ * will be invalid.
<Viewstub>: Usage
<ViewStub
Android: id = "@ + id/hotkey_view_stub"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: layout = "@ layout/hotkey_view_layout"/>
Add viewstub and hotkey_view_layout to your current layout. If you want to use this layout for the activity, you can load it in two ways. When ViewStub is loaded, viewStub will be replaced by its internal layout. In this case, ViewStub will not
This is part of the layout, and ViewStub does not support <merge> labels.
(ViewStub) findViewById (R. id. hotkey_view_stub). setVisibility (View, visibie); or
ViewStub viewStub = (ViewStub) findViewById (R. id. hotkey_view_stub). inflate ();