Android screen adaptation and android adaptation

Source: Internet
Author: User

Android screen adaptation and android adaptation
I. terms and concepts
Four types of screen sizes: small, normal, large, and xlarge
Four density classifications: ldpi (low), mdpi (medium), hdpi (high), and xhdpi (extra high)
It should be noted that xhdpi is added from Android 2.2 (API Level 8.
Xlarge is a category added from Android 2.3 (API Level 9.
DPI is the abbreviation of "dot per inch". The number of dots per inch.
Normal screen: ldpi is 120, mdpi is 160, hdpi is 240, and xhdpi is 320. 480
Ii. Layout
1. Do not use absolute Layout
2. Use match_parent instead of fill_parent whenever possible.
3. Try to use weight Layout
4. Use shape Definition or. 9patch to create a solid color background.
3. adaptive screen size
1. Interface Layout
Store 5 sets of la s based on the Interface
Layout stores some general la s without changing the screen size, such as title and bottom.
Layout_small stores layouts with a screen size less than 3 inch
Layout_normal stores the layout of the screen size less than 4.5 inch
Layout_large stores screen sizes around 4-7 inch
Layout_xlarge stores screen sizes around 7-10 inch
2. ICON resources
You need to prepare 5 sets of image resources, including drawable, drawalbe-ldpi, drawable-mdpi, drawable-hdpi, and drawable-xhdpi Based on the dpi value.
Android has an automatic matching mechanism to select the corresponding layout and image resources.
4. image Production
1. Design
Design the size before the design drawing. Try to use the current popular screen size. For example, the most important currently is the 480 series, 480*800,480*854
The screen level is divided by screen density, and it has nothing to do with pixels. If you want to associate density with pixels, you need a reference object,
Android requires that mdpi 160 is a standard reference, that is, one density can accommodate one pixel on A 320*480 device.
The hdpi corresponds to a density of 240, and a density can contain 1.5 pixels.
2. Cut Graph
The length and width are preferably multiples of 3. The size of the Android log icon is 48*48 m, 72*72 h, 96 * 96x.
The length and width should be a multiple of 2, because the image may have problems if it is an odd number during proportional compression.
Therefore, based on the above two values, if the length and width are multiples of 6
3. Icon adaptation
Suppose that the artist has completed 20*20 design drawings at a resolution of 480*800. If you need to adapt the design to 720*1280, how can we do this?
According to the ratio, the relationship between them is, then in 720*1280, You need to design a 30*30 graph, similarly, put a 40*40 graph on xxhdpi.
4. Icon directory
The 480*800 cut-down graph is placed in the drawable-hdpi directory, and the scaled-up icon is placed in the drawable-xhdpi directory,
The enlarged icon is placed in the drawable-xxhdpi directory.

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.