"Android App Performance Optimization" chapter 8th Graphics

Source: Internet
Author: User

1. The XML setcontentview of 30 parts in the example takes up almost 99% of all time before the end of OnCreate () to Onresume ()

Because the overhead of expanding the layout is significant. Try to use a different layout method. For example, reduce the use of a layer of nested linearlayout, using Reltivelayout to place the control on the first layer

Reduce the number of objects created

2, the Activity content view "Father" is a framelayout.

So when the top layer of your XML is just a framelayout, you end up with two framelayout

You can now use <merge> to merge the two layouts

<framelayout xmlns:android= "Http://schemas.android.com/apk/res/android"

Android:layout_width= "Fill_parent"

android:layout_height= "Fill_parent"

Android:id= "@+id/my_top_layout" >

To be replaced by:

<merge xmlns:android= "Http://schemas.android.com/apk/res/android" >

3. Use <include> reuse layouts

4, Viewstub

<viewstub

Android:id= "@+id/mystubid"

Android:inflatedid= "@+id/myid"

android:layout= "@layout/mylayout"/>

This time the layout mylayout will not be Setcontentview expanded

Viewstub stub = (viewstub) Findviewbyid (r.id.mystubid);

View Inflatedview = Stub.inflate ();//inflatedview defined in Mylayout.xml

Viewstub view = (viewstub) Findviewbyid (r.id.mystubid);

View.setvisibility (view.visible); The viewstub is removed from the parent container. Replace with a layout with ID myID

View = Findviewbyid (R.id.myid);

5. Layout Tools

Android comes with a tool, tools directory: Hierarchyviewer.

The layout can only be checked in the simulator. The real machine needs root.

http://blog.csdn.net/autumn_xl/article/details/40741835

Get  from  get from device 00856cd5d08d2409[viewserverdevice]unable to debug Device:lge- nexus_4-forget from Device 00856cd5d08d2409

Another layoutopt is not found under tools.

6. OpenGL

Android App performance optimization (8th) graphics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.