Android application, we must suffer from a variety of LAYOUT-SW480DP Layout-sw600dp-land layout-sw720dp-port, often do not know their own tablet loading is which layout and have to try, Online a lot of inexplicable tutorials. I have consulted a lot of information to share with you a calculation method to determine which DP resources are loaded on your tablet. In fact, SW is not software, meaning, I guess is shortest width, the shortest breadth.
the SW-XXXX-DP formula is SW *160/dpisuch as 1280*800, SW is the 480*800, SW is 480
The following example, I believe that can better understand the calculation method, where DPI is actually set in Android/device/softwinner/astar-common/astar-y3.mk, no Android source code can be through the ADB shell Getprop Ro.sf.lcd_density obtained.
Model |
Resolution |
Sw |
Dpi= ro.sf.lcd_density |
SW *160/DPI = DP |
H7 (Android5.1) |
1280*720 |
720 |
213 |
720*160/213=540.84 = SW340DP |
H7 (Android4.4) |
1280*720 |
720 |
160 |
720*160/160=720= SW720DP |
A33 Astar-y2 |
1024x768 |
768 |
160 |
768*160/160 =768 = SW720DP |
Brand |
800*480 |
480 |
120 |
480*160/120 =640= SW600DP |
Brand |
800*480 |
480 |
160 |
480*160/160 =480= SW480DP |
After calculating the result by Formula SW*160/DPI, select a DP that is smaller than the result and closest to the value. For example, the example of H7 (Android 5.1) is calculated to be 540.84, if you have a sw480dp under the layout, then here DP is definitely SW480DP, if there is no SW480DP, can only find Sw340dp.land is horizontal screen, port is vertical screen.
How to get the correct layout resources in Android development (LAYOUT-SW480DP Layout-sw600dp-land Layout-sw720dp-port)