天蓬老师2017-04-17 18:03:06
I recommend using the same ratio to adapt to different screens.
For example: 160px as the unit.
Write the corresponding drawable.
If it is 320px, then it is 0.5
If it is 640px, then it is 0.25
And so on. Directly writing PX can adapt to most screens. This is also based on the writing method in Hong Yang's blog on CSDN. But the more troublesome thing is that there are many drawables to maintain. Just adapt to mainstream screens. You can try it. Hope you adopt it!
迷茫2017-04-17 18:03:06
I must recommend the official document I translated: http://blog.csdn.net/wzy_1988...
巴扎黑2017-04-17 18:03:06
For Android adaptation, it is best to use the percentage tool currently provided by Google. That is, the layout is written in the form of percentage. There is almost no need to adapt to the resolution of each size screen, because it is a percentage, which is a bit similar to the front end. It's a trend.
天蓬老师2017-04-17 18:03:06
This is a sub-question, comrade
Even the resolutions of ios products are very different, let alone the tens of thousands of android machines
If you write a 500px wide control, it will only be three points on a 2k screen One, but it already occupies more than two-thirds of the width on a 720*1280 machine, and the UI cannot be viewed
PHP中文网2017-04-17 18:03:06
dp=px*160/dpi
dpi=160 on the device 160dp=160px=1inch
dpi=320 on the device 160dp=320px=1inch
Using dp ensures that at any resolution, the visual effect of 160dp is 1 inch in length