About Android's different resolution picture adaptation

Source: Internet
Author: User

Read a few related blogs, according to their own actual development, summed up a bit.


First of all, the resolution of the image is pixel, that is, PX, such as 72x72 's picture, is the length of the width is 72px; the resolution of the phone screen is similar to the picture, but it also has an important indicator: dpi, called pixel density, represents the number of pixels displayed on a screen that is 1 inches long, In fact, the clarity of the screen is clear, the larger the DPI value of the screen appears clearer.


Why should they fit? Because the phone screen has a wide range of DPI, if you use a fixed pixel image, then this image on the low DPI screen will show the high DPI value of the screen, of course, this premise is based on the original size display, such as the layout file inside the Wrap-content , if the use of limited size, such as 30DP, developed by the people know that this will cause the image compression and stretching, compression is nothing, stretching the picture will be distorted look blurred. So in the context of the demand for visual image experience, we have to do a long screen adaptation. The DPI value and the drawable folder correspond to the following relationships:

DPI Range density
0DPI ~ 120dpi ldpi
120DPI ~ 160dpi mdpi
160DPI ~ 240dpi hdpi
240DPI ~ 320dpi xhdpi
320DPI ~ 480dpi xxhdpi
480DPI ~ 640dpi xxxhdpi


We all know that the Res folder below the Drawable folder is placed in the image, in Eclipse, the system has been automatically generated according to different DPI ldpi, MDPI, hdpi, xhdpi, xxhdpi, xxxdpi and so on folder, Androidstudio inside need to create themselves, these folders are placed in different resolutions of the picture, the order of the above represents the phone screen dpi value, we also know that the system will be running according to the specific phone screen to the corresponding folder below to obtain the picture, But the reality is often cruel, usually to our developer's pictures are only one resolution, if we brutally copy and paste this image under each DPI folder, there will be a variety of situations (if the art is according to 1080x1920 resolution of the phone screen standard to the picture, Picture size 540x960, just occupy half the screen area):

1, if the mobile phone screen size is just the size of the design, the system will go to the XXHDPI folder to obtain the picture, and just show the design size;

2, if the phone screen is 720x1280, then this picture occupies more than half the screen area, the width ratio: 540/720, the length ratio: 960/1280;

3, in the same vein, if the phone screen is 1440x2250, then this image occupies no more than half the screen area.


There will certainly be a lot of developers who will do the same thing: just put the pictures under one folder, others don't. In this case, no matter what kind of screen will go to this folder to get the picture, but the question is put under which folder? In fact, the system in the runtime according to the folder's DPI value and the screen's DPI value scale to enlarge or reduce the picture, for example, if the phone screen is hdpi, the picture is placed in the XXHDPI folder, the system will automatically follow these two DPI scale compressed pictures, if the phone screen is xxxhdpi, Will enlarge the picture, the effect is almost exactly the same as our requirements, but if the picture is placed under the Hdpi folder, the hdpi screen will be more than half the size (as the theory says), if the xxhdpi screen, the system will scale up the picture, But this picture itself occupies half of this screen, this time will be more than half, if the picture is placed under the Xxxhdpi folder, the same xxhdpi screen will be less than the design ratio of the picture.


To sum up, if you have only a set of pictures to do the adaptation, it is best to put only a DPI folder below, choose which folder, it will be based on the current market mainstream phone screen resolution, the current should be xxhdpi screen accounted for the mainstream, and then the picture compression is better than the principle of stretching good, Try selecting a folder with high DPI.






About Android's different resolution picture adaptation

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.