Android screen adaptation principles and android adaptation principles
The screen sizes of Android devices are various, such as Xiaomi's 4 inch, Xoom's 10 inch, resolution, and 800x480,960; the fragmentation problem of the Android version is even more lingering, but it can be divided into two major parts during application design: versions earlier than 3.0 and Versions later than 3.0. What problems will this cause? Let's use three assumptions to explain.
1. Assume that you have two 4 inch devices on your hand. The resolution of device A is 800 × 480, and that of Device B is 1600 × 960. You have designed A 64*64 pixel icon on device A, and it seems to be in the right size, but when it is placed on Device B, it looks like it is only half the size. 2. Assume that device A is 4 inch and Device B is 10 inch. A tab control is placed on top of device A, which has three tabs. When I put it on Device B, the three tabs of the tab control were pulled a long time. The space that originally put the six tabs was only put on three tabs. 3. Assume that device A is installed with Android2.3 and Device B is installed with Android4.0, but Device B is not created with menu, and the style is different. You find it inappropriate for two devices to use the same style of skin.
Google provides a system to solve these problems. Let's go back to the figure above. The drawable folder contains ldpi, mdpi, hdpi, and xhdpi. Dpi indicates pixels/inches, ldpi indicates 120, mdpi indicates 160, hdpi indicates 240, and xhdpi indicates 320. The cell phone resolution is 4 inch, 854 × 480, so the dpi of the cell phone is 854 square plus 480 square sum of squares after the power of 2 divided by 4, the result is about 245. If the application is installed on a Xiaomi mobile phone, the system will call the resources in the drawable-hdpi in the figure. In this way, you only need to set four sets of resources under drawable-ldpi, drawable-mdpi, drawable-hdpi, and drawable-xdpi respectively (the icons can be 3: 4: 6: 8), then we can solve the problem mentioned in hypothesis 1 above.
For devices with the same dpi but different sizes, you can use the layout file to control the layout of various resources. Google divides devices into small (2 ~ 3 inch), normal (about 4 inch), large (5 ~ 7 inch), xlarge (more than 7 inch ). In the preceding example, we can configure the tab columns of three tabs in layout-normal and configure the tab columns of six tabs in layout-xlarge. If the application layout is the same on all devices, layout of different sizes is not considered. The layout * folder shows that the application supports horizontal and vertical screens on hdpi and xhdpi, and the layout of the horizontal and vertical screens is inconsistent, but the layout of devices of different sizes is not considered.
The style before Android3.0 differs greatly from that after Android3.0 (including 3.0). In the figure, the app uses two styles of resources and layout. Android2.3 millet will use drawable-hdpi and layout-hdpi files, and Android4.0 millet will use drawable-hdpi-v11 and layout-hdpi-v11 files.
Android screen adaptation
Can you tell me more? What kind of effect do you want to achieve?
If you want to match multiple screens, you need to write different layout files for different screens.
Compatibility with multiple screens in android Development
I am not a great god.
I just want to help you.
You are too busy to read this.
Defined in values, values-sw360dp-xhdpi, and values-sw480dp-hdpi,
Personally, you can test the results several times.
I wish you success.