Android资源数量有什么限制? [英] What limits are there on the number of Android resources?

查看:155
本文介绍了Android资源数量有什么限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的一个应用程序具有数千个小数据文件,我们目前正在打包这些小数据文件作为资产.如果我们可以将它们打包为原始资源,这将对我们的代码有所帮助.我试图找出每种类型的应用程序可以拥有的资源数量的限制,但是我还没有找到关于此的任何文档.有谁知道Android资源数量的限制?

One of our apps has several thousand small data files that we're currently packaging as assets. It would help our code if we could package them as raw resources. I have tried to track down what the limits are for the number of resources an app can have of each type, but I haven't found any documentation on this. Does anyone know what the limits are on the number of Android resources?

推荐答案

经过大量实验,对于每种资源类型,似乎最多可以拥有16位资源(65,536种资源). (可能会保留一些额外的位以备将来使用,这将减少最大资源数量,但我找不到任何证据.)如果有人可以提供权威的答案会很好,但是一年之后,我会我放弃了.

After a lot of experimenting, it seems that you can have up to 16 bits worth of resources (65,536 resources) for each resource type. (There may be additional bits reserved for future use, which would reduce the max resource count, but I couldn't find any evidence of this.) It would be nice if someone could provide an authoritative answer, but after a year, I'm giving up.

编辑(请参见评论下面是@BT ):基于 hackbod的这个答案在另一个线程中,似乎有,的确,有16位可用,因此任何一种类型最多可以具有65,535个资源(而不是65,536,因为零不可用).另外,请注意,此限制仅适用于单个配置的资源数量(语言环境,像素密度等).用于不同配置的资源变体共享相同的资源ID,并且不会增加计数.因此,实际上您可以拥有超过65,535种任何一种类型的资源(例如,布局或字符串),而不仅仅是任何一种配置.

EDIT (see the comment below by @B T): Based on this answer by hackbod in another thread, It seems that there are, indeed, 16 bits available, so one can have up to 65,535 resources of any one type (not 65,536, because zero is not available). Also, note that this limit applies only to the number of resources for a single configuration (locale, pixel density, etc.). Variations of a resource for different configurations share the same resource ID and don't contribute to the count. So you can actually have a lot more than 65,535 resources of any one type (e.g., layout or string), just not for any one configuration.

这篇关于Android资源数量有什么限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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