Summary of Application performance optimization under Android studido--Layout optimization

Source: Internet
Author: User

    • The success of an application = product design * Performance, then we do not discuss an application design, it is to our lovable and hateful product manager and UI designer to decide! So here are a few steps to discuss how to improve the performance of an application, where the layout optimization problem is discussed first.
Layout optimization
    1. Avoid over-receipt (overdraw), because excessive drawing can waste a lot of CPU,GPU resources,
      Check method:
By opening the developer Options –>GPU mode rendering analysis –> displayed as a bar chart on the screen. Then you will see the situation, the best use of the real machine, the simulator receipt problem.


You can look at the drawn bar chart
Tips: Each bar contains three parts, and blue represents the time of the measurement receipt display list, red represents the time it takes for OpenGL to render the display list, and the yellow Code CPU waits for the GPU's processing time. In the middle of the Green Line code vsync time 16ms, you need to try to control all the bar chart below the Green Line. If you exceed a lot, it means that your layout needs to be optimized.

Analyze layout optimization with Hierarchy Viewer
    1. Turn on Android Device Monitor in two ways,
    2. Go to the interface that you used to encounter with Eclipse, and then open it in Android Device Monitor by diagram
    3. Open the process you want to see
    4. For example, the View Hierarcy can also help you identify areas where rendering performance is relatively low. A red or yellow dot in the view node represents a slower view object. As you step through the application, you can determine whether a view is slow or slow in a particular environment.
      Note that low performance does not necessarily indicate a problem, especially as a ViewGroup object, the more child nodes of view, the more complex the structure, the worse the performance.
      The View Hierarchy window can also help you find performance issues. Just look at the performance metrics (color dots) of each view node, and you can see which of the slowest view objects are measured (layout or drawing), so you can quickly determine which problem to prioritize.
Show GPU Over-drawing
    • You can open settings on your phone--developer options--display GPU over-drawing, which is used to display over-rendering of layouts by different color values, drawing levels from the best to the worst: blue, green, red, reddish.

    • Images from top to bottom represent different levels of overdraw, we try to reduce the red overdraw and see more blue areas in the layout time. Take a look at the Overdraw diagram and our custom layout Overdraw Chart bar
Solve layout optimization problems
      1. Optimize the layout hierarchy
        In Android, when a view is measured and laid out, it is the traversal of the view count. If a view has too many levels, it can seriously affect the speed at which the layout is plotted. Google also mentions in the API documentation that the level of the handout view should not exceed 10 levels. Tips: Early Google used linearlayout as the default root layout in Android, and now the default is relativelayout in Android because of the reason for reducing the layout hierarchy
      2. Reusing layout with < include > tags
        For example, in the UI of the toolbar common set of layouts, and some aspects of a common set of UI layout, you need to consider the problem of reusing tags tips: in android Studio can directly extract the layout, Click Layout and then make a name to extract the include tag.

      3. Detailed analysis of the specific situation, through the above three analysis methods to optimize the layout of the place, and then solve the optimization problem can be .....

Summary of Application performance optimization under Android studido--Layout optimization

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.