简体   繁体   English

处理许多图像资源的最佳方法?

[英]Best way to deal with many image resources?

I have a doubt regarding the best way to deal with many image resources. 我对处理许多图像资源的最佳方法有疑问。 These images are the flags of all the Countries in the world so they are circa 200. Usually I store all the images in the res/drawable folder but in this case, they are too many. 这些图像是世界上所有国家/地区的标志,因此它们大约是200。通常我将所有图像存储在res / drawable文件夹中,但是在这种情况下,它们太多了。 What would you suggest?? 你有什么建议?

( I have to use them in an ImageView in a ListView ) (我必须在ListViewImageView中使用它们)

What's wrong in putting them in your drawable folder? 将它们放入可绘制文件夹有什么问题?

What you could do is two different versions, one for phones that have A2SD were you put them in your drawable folder and the other one downloads the flags to the users sd-card. 您可以做的是两个不同的版本,一个版本用于具有A2SD的电话,您可以将它们放在可绘制的文件夹中,另一个版本将标志下载到用户sd卡中。 At least let the user choose where to save them. 至少让用户选择将它们保存在哪里。

That way if the user wants the can be stored on the sdcard. 这样,如果用户希望可以将其存储在sdcard上。

If you believe that the size of your images will push the size of your APK too high then perhaps create a thumbnail of each flag for most of your display purposes and use a WebView with a link to a larger version. 如果您认为图片大小会使APK的大小过高,则可以为大多数显示目的创建每个标志的缩略图,并使用带有较大版本链接的WebView This however will eat battery life & data & would only be available when the user is connected to the network. 但是,这会消耗电池寿命和数据,并且仅在用户连接到网络时可用。

Not recommended but if there is no other choice... 不推荐,但如果没有其他选择...

You could also download all of these flags on app initial start if it's the initial download of the apk you're worried about. 如果这是您担心的apk的初始下载,您也可以在应用初始启动时下载所有这些标志。

Otherwise keep your image sizes small and/or low quality to reduce the impact. 否则,请保持图像尺寸较小和/或质量较低,以减少影响。

据我所知,android到底将apk文件限制为50M。当您拥有大量资源时,您的应用程序可能会超过此限制。这是您的问题吗?

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

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