安卓:从资产/可绘制文件夹的访问图像文件夹、图像、资产

2023-09-12 09:23:31 作者:時光叫莪别迴頭↑

该应用程序我目前工作的有数百幅图像。目前,我将它们存储在绘制对象文件夹中。我在想动他们都Assets文件夹。

The app I am currently working on has hundreds of images. At the moment I store them in the 'Drawable' folder. I was thinking about moving all of them to Assets folder.

我的问题是:是否有使用这两种方法时,在性能上有什么区别?

My question is: Is there any difference in performance when using both approaches?

推荐答案

我不认为因此在使用这两个文件夹的表现有点差,我想用绘制文件夹,你可以得到轻松的图像(所有将被索引在R档,这使得它更快(和容易得多!)来加载它们。),如果你想从资产使用它,那么你必须使用 AssetManager 然后用 AssetFileDescriptor 你必须让这些图像。

I don't think so there is bit difference in performance of using these two folders, I think using drawable folder you can get easily images (All will be indexed in the R file, which makes it much faster (and much easier!) to load them.), and If you want to use it from asset then you have to use AssetManager then using AssetFileDescriptor you have to get those images.

资产,也可以组织成一个文件夹层次结构,这是不 通过资源的支持。这是管理数据的方式不同。 虽然资源覆盖大多数的情况下,资产有其 偶尔使用。

Assets can also be organized into a folder hierarchy, which is not supported by resources. It's a different way of managing data. Although resources cover most of the cases, assets have their occasional use.

RES /绘制目录中的每个文件都有一个pre-编译ID 它可以很容易地通过R.id. [RES ID]进行访问。这是有用的,以 快速,轻松地访问图像,声音,图标...

In the res/drawable directory each file is given a pre-compiled ID which can be accessed easily through R.id.[res id]. This is useful to quickly and easily access images, sounds, icons...

 
精彩推荐
图片推荐