为什么我的布局不与密度无关?
如下所示的布局看起来非常不同,具体取决于投影到的屏幕尺寸。我知道我可以对每个屏幕尺寸使用不同的布局来改进这一点,但考虑到我已经遵循了 android 多屏幕支持文档中描述的最佳实践(使用 dps,没有绝对布局等),我并不期望结果看起来像这么糟糕,所以我担心还有进一步的根本问题。
My layout as shown below looks very different depending on what screen size it is projected on to. I'm aware I can improve this somewhat using different layouts for each screen size but considering I have followed the best practises described in the android multiple screen support documentation (using dps, no absolute layouts etc) I wasn't expecting the results to look this bad so I fear there is a further underlying problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的布局很好,完全符合我的预期。您不应该将密度独立像素与完全动态布局混合在一起。
DP只是表示根据密度类型计算的值。密度本身与屏幕分辨率无关。
60dp
是mdpi
设备上的60px
,无论屏幕是全高清还是 480x360。但结果当然是非常不同的,因为计算出的60px
在高清屏幕上不算什么,但在小屏幕上却很多。您没有其他可能性,只能根据屏幕尺寸/分辨率提供不同的布局。
Your layout is fine and completely as I would expect it. You shouldn't mix up density independent pixels with fully dynamically layouts.
DP just means that the value is calculated according the density types. The density itself has nothing to do with screen resolutions.
60dp
are60px
on amdpi
device, it doesn't matter if the screen is full HD or just 480x360. But the result is, of course, very different because the calculated60px
are nothing on a HD screen but a lot on a small one.You have not other possibility but to provide different layouts according to the screen size/resolution.