Android Interface Optimization method

Source: Internet
Author: User

After we launched an app, there are some experience problems in the middle, one obvious is the interface lag, for this problem we have taken the following measures, has played some effect.

1. Optimize the interface level

The main tool used in this process is to combine the interface levels that can be merged to reduce the rendering of the interface, which is where the developer settings display over-rendering, where the red area must be optimized.

2. Reduce the number of UI refreshes

Reducing the number of UI refreshes is a good interface optimization, especially for collection pages such as the ListView.

"1" Use delay to reduce the interface refresh times: We have made a delay mechanism, each refresh delay 1s, when the second there is a refresh request to continue to postpone the refresh time, up to 5s when the interface must be refreshed, this effect is very obvious.

"2" before refreshing the interface to determine whether really need to refresh: For other fixed interface, we will determine whether the interface refresh, if the current display and to display the same, there is no need to refresh.

"3" Cache interface: If we want to always update the interface in the ListView, and these updates will not result in the order of the ListView, then the view will be a cache, directly to the view update.

"4" Static interface: This is a way to cache the interface, for a complex interface using the static variable cache, each time the interface is built, the static view is adjusted.

3. Interface model and data model separation

The original time we before the view display, the data model will be processed, after processing will be displayed on the interface, these processing logic should be extracted in the asynchronous thread, to generate a concrete interface model, displayed directly to show.

4. Split IO operations from the main thread

This is a concrete embodiment of 3, the operation of files, databases and other IO operations from the main thread stripped out, to avoid blocking the main thread.

5. Avoid resource competition.

Minimize the amount of resources that are generated, such as minimizing the operation of new in the program, and reasonably controlling the number of threads. When memory resource consumption is severe, garbage collection is frequently picked up and a skip frame is often present in the log.

Android Interface Optimization method

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.