简体   繁体   English

我可以只将图像放在 xxhdpi 文件夹中吗

[英]Can I put images only in xxhdpi folder

I have an app with some images exists only in the xxhdpi folder.我有一个包含一些图像的应用程序仅存在于xxhdpi文件夹中。 When I try to access to those imagse, through context.getResources(...) I see in some phones it crash.当我尝试通过context.getResources(...)访问这些图像时,我在某些手机中看到它崩溃了。

is it possible that it crash because those phones doesn't supports the density in xxhdpi and therefore it cannot find them?是否有可能因为这些手机不支持 xxhdpi 中的密度而导致它无法找到它们而崩溃? or even though the phone is not in density for xxhdpi , it still needs to find it, so it doesn't matter?或者即使手机没有xxhdpi密度,它仍然需要找到它,所以没关系?

In bottom line, my question is what happens if I put some images only in xxhdpi folder, and the phone doesn't supports by default in xxhdpi resolution? xxhdpi ,我的问题是,如果我只将一些图像放在xxhdpi文件夹中,并且手机默认不支持xxhdpi分辨率,会发生什么?

是的,它会崩溃,相反,您可以将它们放在 Drawable 的默认文件夹中。

this isn't best solution to MOVE pretty big image file from xxhdpi to default folder as accepted answer suggests... it will be scalled everytime when it will be fetched, so on xxhdpi devices it will be scaled-up 3x - unnecessary work.这不是将相当大的图像文件从xxhdpi到默认文件夹的最佳解决方案,正如公认的答案所暗示的那样......每次获取它时都会调用它,因此在xxhdpi设备上它将被放大 3 倍 - 不必要的工作。 besides that some old devices may have problem with loading such big picture, due to max bitmap size limitation.此外,由于最大位图大小限制,一些旧设备可能无法加载如此大的图片。 it would be better to COPY this file to mdpi folder and rescale it in there (3x smaller) - on xxhdpi will be used original one, on all other scaled version, but not so enormous最好将此文件复制到mdpi文件夹并在其中重新缩放(小 3 倍) - 在xxhdpi上将使用原始文件,在所有其他缩放版本上,但不是那么大

ofc best way is to put properly scaled image in every density bucket ofc 最好的方法是在每个密度桶中放置适当缩放的图像

If it is really a big image and you want to use it, then put it in nodpi folder.如果它真的是一个大图像并且你想使用它,那么将它放在 nodpi 文件夹中。 And if it is a normal image then it is better to scale images with different sizes and put them in a respected folder.如果它是普通图像,那么最好缩放不同大小的图像并将它们放在受尊重的文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM