Android屏幕尺寸HDPI、LDPI、MDPI

发布于 2024-11-10 07:42:39 字数 177 浏览 9 评论 0原文

我有一个需要适合所有屏幕尺寸的背景。我有三个文件夹,hdpildpimdpi 用于绘图,但在模拟器中没有任何关于分辨率的参考hdpi 是什么,mdpildpi 是什么。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

神妖 2024-11-17 07:42:39

您应该阅读支持多个屏幕。您必须在模拟器上定义 dpi。 240 是 hdpi,160 是 mdpi,低于该值通常是 ldpi。

摘自上面的 Android 开发者指南链接:

320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).  
480dp: a tweener tablet like the Streak (480x800 mdpi).  
600dp: a 7” tablet (600x1024 mdpi).  
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).

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:

320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).  
480dp: a tweener tablet like the Streak (480x800 mdpi).  
600dp: a 7” tablet (600x1024 mdpi).  
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
愁杀 2024-11-17 07:42:39

更新: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)

肤浅与狂妄 2024-11-17 07:42:39

就最终解决方案而言,该文档相当粗略。经过一番研究,这是我得出的解决方案: 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文