gpt4 book ai didi

android - 关于 drawable-hdpi、drawable-mdpi、drawable-ldpi 和 drawable 的混淆

转载 作者:太空狗 更新时间:2023-10-29 12:54:00 27 4
gpt4 key购买 nike

我正在进行一个非常大的项目,该项目是在 android 1.5 时代开始的。

这个项目随着 android 的发展而发展,目前支持 2.3 及更高版本。

现在我遇到了这个问题,我在 drawable-hdpi、drawable-mdpi、drawable-ldpi 以及 drawable 文件夹中有很多可绘制对象。

一般来说,这 3 个文件夹(drawable-hdpi、drawable-mdpi、drawable-ldpi)的概念对我来说很清楚,但我对 drawable 文件夹中的图像感到困惑。

例如,我有一个名为 myimage.png 的图像,该图像存在于分辨率分别为 72x72、48x48、36x36 的 drawable-hdpi、drawable-mdpi、drawable-ldpi 文件夹中,但该图像也存在于 drawable 文件夹中。

我的问题是为什么?什么时候使用可绘制文件夹中的图像?这张图片忘记删除了吗?在某些情况下使用它?我试图删除此图像,应用程序运行正常。我也只放了一个分辨率为 72x72 的绿色,并且从未绘制过此图像

那么有人可以向我说明 drawable 文件夹的存在吗?

我知道,如果我没有 dhpi、mdpi 和 ldpi 文件夹,那么我需要将图像放入可绘制对象中,但是当存在这 3 个文件夹时,将图像放入可绘制对象中有什么意义?

谢谢

编辑

还有一个问题,如果我在 drawable-hdpi 中有图像但在 ldpi 中没有而不是在 mdpi 中怎么办。假设我们的手机具有 mdpi 分辨率密度......会发生什么?

最佳答案

drawable folder 用于默认图像,如果在相应的文件夹中找不到图像,那么它将查找 drawable 文件夹。

我在文档中找到了这个短语:

For example, imagine you have an application icon, icon.png, and need unique version of it for different locales. However, two locales, English-Canadian and French-Canadian, need to use the same version. You might assume that you need to copy the same image into the resource directory for both English-Canadian and French-Canadian, but it's not true. Instead, you can save the image that's used for both as icon_ca.png (any name other than icon.png) and put it in the default res/drawable/ directory. Then create an icon.xml file in res/drawable-en-rCA/ and res/drawable-fr-rCA/ that refers to the icon_ca.png resource using the element. This allows you to store just one version of the PNG file and two small XML files that point to it. (An example XML file is shown below.)

请引用这个link为了更清楚。

关于android - 关于 drawable-hdpi、drawable-mdpi、drawable-ldpi 和 drawable 的混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8832664/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com