Drawable-hdpi、Drawable-mdpi、Drawable-ldpi Android [英] Drawable-hdpi, Drawable-mdpi, Drawable-ldpi Android

查看:30
本文介绍了Drawable-hdpi、Drawable-mdpi、Drawable-ldpi Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Android 1.5,但我现在已迁移到最新版本.所以在Android 1.5中只有一个drawable"文件夹,而现在Android项目中有3个不同的存放图片的文件夹.

I was working on Android 1.5, but I have now moved to the latest version. So there is only one "drawable" folder in Android 1.5, but now there are three different folders for storing images in the Android project.

我发现这三个文件夹的一些文章说

And I have found some articles for these three folders that says

  1. hdpi 表示高 dpi
  2. mdpi 表示中等 dpi
  3. ldpi 表示低 dpi

但这三个文件夹的确切用途是什么,我应该什么时候使用特定文件夹来存储图像?

But what is the exact purpose of these three folders and when should I use a particular folder to store images in?

推荐答案

要声明要用于不同屏幕的不同布局和位图,您必须将这些替代资源放在不同的目录/文件夹中.

To declare different layouts and bitmaps you'd like to use for the different screens, you must place these alternative resources in separate directories/folders.

这意味着如果你为 xhdpi 设备生成一个 200x200 图像,你应该在 150x150 中为 hdpi 生成相同的资源100x100 用于 mdpi75x75 用于 ldpi 设备.

This means that if you generate a 200x200 image for xhdpi devices, you should generate the same resource in 150x150 for hdpi, 100x100 for mdpi, and 75x75 for ldpi devices.

然后,将文件放在适当的可绘制资源目录中:

Then, place the files in the appropriate drawable resource directory:

MyProject/
    res/
        drawable-xhdpi/
            awesomeimage.png
        drawable-hdpi/
            awesomeimage.png
        drawable-mdpi/
            awesomeimage.png
        drawable-ldpi/
            awesomeimage.png

任何时候你引用@drawable/awesomeimage,系统都会根据屏幕的密度选择合适的位图.

Any time you reference @drawable/awesomeimage, the system selects the appropriate bitmap based on the screen's density.

这篇关于Drawable-hdpi、Drawable-mdpi、Drawable-ldpi Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆