Android:从资产/可绘制文件夹访问图像 [英] Android: Accessing images from assets/drawable folders

查看:29
本文介绍了Android:从资产/可绘制文件夹访问图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发的应用有数百张图片.目前我将它们存储在Drawable"文件夹中.我正在考虑将它们全部移到 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?

推荐答案

我不认为使用这两个文件夹在性能上有一点差异,我认为使用 drawable 文件夹可以获得轻松图像(所有图像都将在 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 也可以组织成文件夹层次结构,这不是有资源支持.这是一种不同的数据管理方式.尽管资源涵盖了大多数情况,但资产有其偶尔使用.

  • 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/drawable 目录中,每个文件都有一个预编译的 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...

这篇关于Android:从资产/可绘制文件夹访问图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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