Android Performance optimization

Source: Internet
Author: User

Tag: Receiver speed also factor listview memory using tag operation

1. Layout optimization

<include> tags are used primarily for layout reuse,<merge> labels and <include> with reduced layout levels, Viewstub provides on-demand functionality, The layout in Viewstub is loaded into memory when needed, providing the program's initialization efficiency.

<include> tag only supports attributes that start with Android:layout

2. Drawing optimization

Drawing optimization refers to the OnDraw method of view to avoid performing a large number of operations, which is mainly reflected in two aspects:

A, do not create a new local object in OnDraw. Because the OnDraw method may be called frequently, it produces a large number of temporary objects in a flash.

B, do not take time-consuming tasks in the OnDraw method. Because this will cause the view to not draw smoothly.

3. Response Speed

Android rules that if the activity fails to respond to screen touch time within 5 seconds or if the keyboard input event occurs, the ANR will appear if the broadcastreceiver is not completed within 10 seconds.

4, the optimization of the ListView

Adopt Viewholder and avoid time-consuming operation in GetView;

Depending on the sliding state of the list, the frequency of task execution is controlled, such as when the list is sliding quickly, it is obviously not suitable to open a large number of asynchronous tasks;

Try turning on hardware acceleration to make the ListView slide smoother.

The optimization of the ListView applies to the GridView.

5. Other optimization

The optimization of bitmap is mainly done by bitmapfactory.options to sample the images as needed.

Android Performance 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.