1, adapter and Adapterview reuse the historical cache (item layout and data cache).
2, data paging display (using operation to guide users)
3, optimize the layout file XML. (layout try not to exceed 5 layers)
4, optimize the activity of the background image. Use Getwindow.setbackgrouddrawable (ID) to set the background map, using the system's default top-level to improve efficiency.
5. Setting the background in a custom theme
6, use Stubview on-demand load, reduce memory consumption
Stubview the layout to load:
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/ Res/android " android:layout_width=" match_parent " android:layout_height=" Match_parent "Android:o rientation= "vertical" ><textview android:id= "@android: Id/text1" android:text= "Portrait Mode" Android:layout_width= "Wrap_content" android:layout_height= "wrap_content"/> <seekbar android: Id= "@android: id/progress" android:layout_width= "match_parent" android:layout_height= "Wrap_content"/> </LinearLayout>
Lazy loading of the main interface:
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/ Res/android " android:layout_width=" match_parent " android:layout_height=" match_parent "> < Button android:id= "@android: Id/button1" android:text= "Load" android:layout_width= "Wrap_content" Android:layout_ height= "Wrap_content"/> <viewstub android:id= "@+id/stub" android:inflatedid= "@+id/subTree" Android: layout= "@layout/mystub_portrait" android:layout_width= "match_parent" android:layout_height= "Match_parent"/> </LinearLayout>
Implementation of Stubview Loading
public class Stubviewloadactivity extends Activity { @Override protected void OnCreate (Bundle Savedinstancestate) { super.oncreate (savedinstancestate); Setcontentview (r.layout.delay_load); Button btn = (button) Findviewbyid (Android. R.id.button1); Btn.setonclicklistener (New Onclicklistener () { @Override public void OnClick (View v) { v.setenabled ( FALSE); Viewstub stub = (viewstub) Findviewbyid (r.id.stub); View inflated = Stub.inflate ();}} );} }
7. Use child threads and background tasks to complete time-consuming operations
Androidui Performance Optimization