Android screen Adaptation

Source: Internet
Author: User

I. About layout 1, do not use absolute Layout 2, try to use match_parent instead of fill_parent. 3, can use the weight of the place as far as possible the use of weight (android:layout_weight) 4, if it is a solid color background, as far as possible using the shape of Android custom. 5. If you need to fit at a specific resolution, you can create a new Layout-hxw.xml folder on the Res directory. For example, to fit the 1080*1800 screen (Meizu MX3 with this resolution), create a new Layout-1800x1080.xml folder and define the layout below. The Android system will first look for layouts with the same resolution and, if they don't exist, use the default layout under layouts. Second, about the picture production 1, about the design: Design plan first set a size to design, and as far as possible in the most popular screen size (such as the current proportion of the screen is more than the 480 series, that is 480*800 or 400* 854, the following icon making is also on a sub-basis for proportional conversion) on the design. First look at the level of the screen:
Screen level Screen density Ratio (relative) Physical Size (inches) Pixel size The usual resolution
ldpi 120 3 0.75 1 120
mdpi 160 4 1 1 160 320*480
hdpi 240 6 1.5 1 240 480*800
xhdpi 320 8 2 1 320 720*1280
xxhdpi 480 12 3 1 480 1080*1800
Description: Screen level: Note that the screen level is graded by density, not related to pixels. If density and pixels are not to be related, a frame of reference is required, and Android uses the MDPI level as the standard reference screen, which means that the cell at 320*480 resolution has a density that can hold one pixel. The other density levels are then compared on this basis. If ideally, the 480*800 screen can accommodate a density of 1.5 pixels. Physical size: in inches instead of pixels, it's said that an inch is the same size in any resolution, but the actual size of the pixels in a cell phone with different densities is not the same (which is why Android phones need to be adapted). And that's the point. Assuming that 1 pixels show 1 inches at 160 density, 1 pixels will show about 240 inches on a 0.67 density basis and 320 inches at 0.5 density. So there is a situation, a pixel on the computer, on different phones to see the actual size is not the same. So how do you make the "design effect" look like the area on a different phone? It is also assumed that a pixel at 160 density is displayed in a density, also assumed to be an inch. How many pixels will it take to display within an inch of the 240 density level? The answer is 1.5 pixels (based on the rate conversion). Knowing the relationship, the next step is the creation of the icon. 2, about transduction. There are a few suggestions about transduction: first, the length of the width is preferably a multiple of 3 (according to the Android recommended logo icon size is (MDPI), (hdpi), (xhdpi) the minimum number of conventions). Second, the length of the width is preferably even. Because odd numbers can be problematic when they are being compressed. Third, according to the above two, if the length of the width is a multiple of 6 ideal. Finally, if you can stretch without changing the design intent, such as a solid color background, use the Android 9path tool to create a. 9 image. 3, about the matching of icons. And then everything is not related to the design manuscript. Based on a well-cut graph, it is based on the proportional relationship of screen density, pixel, and actual size. If the design division in the 480*800 resolution of the design, and cut the picture, if you need to fit the 720*1280 screen, how to do? Depending on the ratio, their relationship is 2:3, so you need to make icons in 1.5 times-fold proportions, such as when you cut a 20*20 pixel figure in 480*800 's design, then you need to create an icon that is equal to 30*30 pixels, so that the same icon is 480* The 800 screen is the same as the actual size shown on the 720*1280 screen. Similarly, if you need to adapt xxhdpi you need to create an icon that is equal to 40*40 pixels on a 20*20 basis. 4, about the directory of icons, 480*800 cut downFigure we placed in the DRAWABLE-HDPI directory, according to the 2:3 enlarged icon placed in the DRAWABLE-XHDPI directory, according to twice times the enlarged icon placed in the DRAWABLE-XXHDPI directory. Android will first find the corresponding directory according to the density of mobile phone resources, such as 408*800 resolution of the phone if the density is 160, then automatically load drawable-hdpi This directory icon, if 720* 1280 density is 240 of the mobile phone automatically loaded drawable-xhdpi the icon under this directory. If there is no this folder, then find and 240 the closest corresponding density folder. Third, the other next to say that the estimate will let you down, according to the above steps can not completely solve the problem of adaptation, can only be approximate adaptation, and even if the above steps are probably appropriate, the actual effect on the phone also has a discrepancy. For example Meizu MX3 resolution is 1080*1800, the standard case density is 480, but his density is about 524, and 480 close, that is, will find drawable-xxhdpi this resource file. In other words, you cut the image in 480*800 resolution and then press twice magnification icon on this phone to show the effect is still smaller than the actual. The other problem is 540*960 or 640*960, whose density is likely to be either close to 240 or maybe 320. The actual size shown on these phones may also be large or small, as a result of the drawings cut down on the 480*800 design and the adaptations made. To sum up, I just share my understanding and experience, but not perfect for the screen, just as a tip, if you pass by and see this advice, if you happen to have a better solution to fit, please advise.

Android Screen Fit

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.