android 适配问题
PHPz
PHPz 2017-04-17 18:01:06
0
7
586

在布局的时候px明显更适合适配,不用考虑像素密度,只需要知道分辨率就可以,为什么官方还推荐dp呢

PHPz
PHPz

学习是最好的投资!

reply all(7)
Peter_Zhu

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!

迷茫

I must recommend the official document I translated: http://blog.csdn.net/wzy_1988...

巴扎黑

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.

PHPzhong

I recommend an article to you http://www.jianshu.com/p/f188...

Peter_Zhu

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

洪涛

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

Peter_Zhu

Now I use Hongyang’s autolayout

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template