Android multi-screen adaptation

Source: Internet
Author: User

Problem:

During the test, it is found that the Display Effect of applications on different monitors is different (some texts cannot be completely displayed). Naturally, the screen adaptation problem occurs.

Sort the rules as follows:

(1) several concepts

1. Screen size: the size of the Screen, that is, the diagonal line length (unit: inch-inch)

2. Screen density: Screen density, that is, number of pixels per unit length (pots/inches)

3. Resolution, that is, the total number of pixels on the screen (width * height)

4. Density-independent pixel (dp) independent pixel Density. The standard is 160dip. That is, 1dp corresponds to 1 pixel. The calculation formula is px = dp * (dpi/160). The larger the screen density, the more pixels corresponding to 1dp.

(2) screen classification (size & density)

1. Change the number of pixels and the size of the text, as shown in

Each category has its minimum resolution, as shown in the following figure. You can divide the categories based on the resolution:

2. provide different images by screen density, as shown in

Note1: match the above two types for reference.

Note2: there are also two types of products designed for horizontal (landscape) and vertical (portrait), which are rarely used and will not be described here.

(3) how Android looks for optimal resources

1. exclude resources that do not match the device settings

2. Search by qualifier in order

3. Whether the resource path exists under the qualifier

4. Exclude the resource paths that are not included in the qualifier

5. continue to search for different qualified words until corresponding resources are found.

As shown in:

(4) project steps:

1. configuration in manufest

    <supports-screens 

Android: anyDensity = "true"

Android: largeScreens = "true"

Android: normalScreens = "true"

Android: smallScreens = "true"

Android: xlargeScreens = "true"/>

2. Create a new resource folder.

A, Layout

As shown in:

B, Drawable

As shown in:

In drawable, the standard is mdpi (160 dpi ). The ratio is 3: 4: 5: 6, as shown in:

Related Article

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.