I. About layout adaptation
1. Do not use absolute layout
2, try to use match_parent instead of fill_parent.
3, can use the heavy place as far as possible to use the weight (android:layout_weight)
4, if it is a solid color background, try to use the shape of android to Customize.
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 then 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:
The design plan first set a size to be designed, and as far as possible in the most popular screen size (for example, 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 and not related to pixels. If you want to make the density and pixel relationship, you need a frame of reference,Android use mdpi level as the standard reference screen, that is, in 320*480 The resolution of the phone on the previous density 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:
Units are in inches instead of pixels, and the size of an inch at any resolution is the same, but the actual size of the pixels in a cell phone with different densities is not the same (that's why Android phones need to be adapted).
And that's the point.
Assuming that 1 pixels show 1 inches at density, 1 pixels in the density is based on the display of approximately 0.67 inches, in the Density display 0.5 inches. 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 is displayed in a density under the density, also assumed to be an inch. How many pixels will it take to display within an inch of the 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 several suggestions about transduction:
First, the length of the width is preferably 3 Span style= "font-family: the song Body;" Multiple (according to android recommended logo Span style= "font-family: ' Times New Roman ';" >48 ( mdpi Span style= "font-family: the song Body;" >), 72 ( hdpi 96 Span style= "font-family: the song Body;" > ( xhdpi ) the minimum number of conventions obtained).
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 division480*800resolution, and cut the diagram, if you need to fit720*1280screen, what should I do? According to the proportions, their relationship is2:3, so you need to follow 1.5 times timesscale making icons, such as when you480*800on the design manuscript cut down a20*20pixel graph, then you need to make a magnification30*30pixel icons so that the same icon480*800the screen and720*1280the actual size shown on the screen is just the same. Similarly, if you need to fitxxhdpiyou need to20*20on the basis of making a equal ratio amplified into40*40the icon for the pixel.
4, about the directory of icons,480*800 cut down the figure we placed in the drawable-hdpi directory, in accordance with the 2:3 enlarged icon placed in drawable-xhdpi directory, follow 2 The magnified icon is placed in the drawable-xxhdpi directory.
Android will first find resources for the corresponding directory based on the density of the phone.
For example, 408*800 resolution of the mobile phone if the density is a , then automatically load drawable-hdpi This directory icon,
If the 720*1280 density is the drawable-xhdpi of the mobile phone automatically loading the icon under this directory. If you do not have this folder, look for the closest corresponding density folder.
Third, other
Next to say the estimate will let you down, according to the above steps can not completely solve the problem of adaptation, can only be appropriate, 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, it will look for files under this drawable-xxhdpi resource. 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 near or 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.
There are two questions, as follows
3. Is there any number of errors in the icon adaptation? What if the screen scale of the 720*1280 should be 1.5/2?
4. About the icon directory, according to 1.5/2 amplification should be placed in the drawable-xhdpi directory it? Mobile phone If the density is 160, should also be moved to load mdpi this directory it? The density is 240 of the mobile phone should also be automatically loaded drawable-hdpi the icon in this directory, right? |
Android Screen Adapter recommendations