Android屏幕尺寸HDPI、LDPI、MDPI
我有一个需要适合所有屏幕尺寸的背景。我有三个文件夹,hdpi
、ldpi
和 mdpi
用于绘图,但在模拟器中没有任何关于分辨率的参考hdpi
是什么,mdpi
和 ldpi
是什么。
I have a background that I need fit in all screen sizes. I have three folders, hdpi
, ldpi
and mdpi
for drawables, but in the emulator there isn't any referense to what resolution hdpi
is and what mdpi
and ldpi
are.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该阅读支持多个屏幕。您必须在模拟器上定义 dpi。 240 是 hdpi,160 是 mdpi,低于该值通常是 ldpi。
摘自上面的 Android 开发者指南链接:
You should read Supporting multiple screens. You must define dpi on your emulator. 240 is hdpi, 160 is mdpi and below that are usually ldpi.
Extract from Android Developer Guide link above:
更新:2014 年 7 月 30 日
如果您使用 Android Studio,请确保您至少拥有 144x144 资源并使用“FILE-NEW-IMAGE ASSET”。 Android Studio 将为您在所有文件夹中制作正确的图像文件:)
正如文档所述 ,按如下方式调整位图:
几乎每个应用程序都应该为不同的屏幕密度提供替代的可绘制资源,因为几乎每个应用程序都有一个启动器图标,并且该图标在所有屏幕密度上都应该看起来不错。同样,如果您的应用程序中包含其他位图可绘制对象(例如应用程序中的菜单图标或其他图形),您应该为不同的密度提供替代版本或每个版本。
注意:您只需为位图文件(.png、.jpg 或 .gif)和九路径文件 (.9.png) 提供特定于密度的可绘制对象。如果您使用 XML 文件来定义形状、颜色或其他可绘制资源,则应将一份副本放在默认可绘制目录 (drawable/) 中。
要为不同的密度创建替代位图可绘制对象,您应该遵循四种通用密度之间的 3:4:6:8 缩放比例。例如,如果您有一个适用于中等密度屏幕的 48x48 像素可绘制位图(启动器图标的大小),则所有不同的尺寸应为:
低密度 (LDPI) 为 36x36
48x48 用于中密度 (MDPI)
72x72 用于高密度 (HDPI)
96x96 用于超高密度 (XHDPI)
144x144 用于额外超高密度 (XXHDPI)
192x192 实现超高密度 (XXXHDPI)
UPDATE: 30.07.2014
If you use Android Studio, make sure you have at least 144x144 resource and than use "FILE-NEW-IMAGE ASSET". Android Studio will make proper image files to all folders for you : )
As documentation says, adjust bitmaps as follows:
Almost every application should have alternative drawable resources for different screen densities, because almost every application has a launcher icon and that icon should look good on all screen densities. Likewise, if you include other bitmap drawables in your application (such as for menu icons or other graphics in your application), you should provide alternative versions or each one, for different densities.
Note: You only need to provide density-specific drawables for bitmap files (.png, .jpg, or .gif) and Nine-Path files (.9.png). If you use XML files to define shapes, colors, or other drawable resources, you should put one copy in the default drawable directory (drawable/).
To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8 scaling ratio between the four generalized densities. For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screen (the size for a launcher icon), all the different sizes should be:
36x36 for low-density (LDPI)
48x48 for medium-density (MDPI)
72x72 for high-density (HDPI)
96x96 for extra high-density (XHDPI)
144x144 for extra extra high-density (XXHDPI)
192x192 for extra extra extra high-density (XXXHDPI)
就最终解决方案而言,该文档相当粗略。经过一番研究,这是我得出的解决方案: Android 启动屏幕图像尺寸适合所有设备
它基本上是针对启动屏幕的,但它完全适用于应该占据全屏的图像。
The documentation is quite sketchy as far as definitive resolutions go. After some research, here's the solution I came to: Android splash screen image sizes to fit all devices
It's basically guided towards splash screens, but it's perfectly applicable to images that should occupy full screen.
看看这个很棒的转换器。 http://labs.rampinteractive.co.uk/android_dp_px_calculator/
Check out this awesome converter. http://labs.rampinteractive.co.uk/android_dp_px_calculator/