Android screen pixel density adaptation detailed

Source: Internet
Author: User

When it comes to pixel density, let's figure out what pixel density is, which literally means the number of pixels in a certain size area on the phone screen. In Android development,

We typically use a unit of pixel density per inch (dpi) to represent the pixel density of your phone's screen, and the DPI conversion method is as follows:

Step 1: Calculate the bevel pixel length of the phone screen:

Step 2: Use the screen bevel pixel length to remove the screen size on the phone to get DPI

So, with such a formula we can easily understand the DPI, is actually the angle of the pixel length and the size of the phone screen a ratio, and we currently each Android phone

is to differentiate the pixel density of the phone screen by such a DPI value.

In Android generally speaking mobile phone screen per inch pixel density values are divided into: 0~120dpi~160dpi~240dpi~320dpi~480dpi~640dpi, such as several intervals, respectively, ldpi, MDPI, hdpi, xhdpi, xxhdpi, Xxxhdpi such a few words to mark, these words believe that the students in the drawable resources have seen, By putting the corresponding DPI drawable resource into the corresponding drawable directory, you can achieve drawable resources that display different pixel densities on different pixel density screens.

On the other hand, in layout resources, DP units are automatically converted to corresponding PX values based on the current screen pixel density, so we generally require that you use DP as the unit of length in layout.

Android screen pixel density adaptation detailed

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.