/ Android的图像资产或资源/原材料 [英] Android images in /assets or res/raw

查看:82
本文介绍了/ Android的图像资产或资源/原材料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我希望把一堆图像的文件夹结构,例如,我要建一个沙滩的应用程序,每个海滩通过我的沙滩详细的活动取决于从我的海滩列表中选择海滩显示。那么我想从那个特定的海滩显示五个图像。每个海滩将有一个文件夹对应于海滩的_id一个名称,然后五个文件夹,image1.jpg,image2.jpg ... image5.jpg图像。我应该放在/ RES /原始文件夹中的文件夹和图像或/资产文件夹去的最好/最简单的方法。

If I wanted to put a bunch of images in a folder structure, e.g.. I’m building a beach app and each beach is displayed via my beach detail activity depending on the beach selected from my beach list. I then want to display five images from that particular beach. Each beach will have a folder with a name that corresponds to the _id of the beach and then five images in that folder, image1.jpg, image2.jpg… image5.jpg. should I put the folders and images in the /res/raw folder or the /assets folder for the best/easiest way to go.

干杯,

麦克。

推荐答案

资产将包含列表允许你创建子目录(组文件的目录)指出,他们没有名字的限制,但是你只能通过资产管理器访问它( )对于一个给定的目录和open()用于获取文件的的InputStream上列出的文件。

Assets will allow you to create subdirectories (group files in directories) note that they have no name restrictions however you can only access it via Assets Manager which contains list() for listing files under a given directory and open() for obtaining a file's InputStream.

资源,而不是,允许您访问的文件夹中的文件,但不能创建子文件夹,而且必须将文件在正确的地方,以便位图去 / RES /绘制 / RES /布局等布局XM​​LS。 Resouces很容易访问对您的code等部位,因为他们有一个标识符。 由于要使用 RES /生文件夹,这意味着你不能在其中创建一个子文件夹,您的图片不会COM pressed,所以把他们无COM preSS并考虑他们将大量的图片,那么你的应用程序将是一个有点沉重。

resources instead, allow you to access the files in the folders but you cannot create subfolders, moreover you must place the files in the right place so bitmaps go in /res/drawable, layout xmls in /res/layout and so on. Resouces are easy to access for other parts of your code since they have an identifier. Since you want to use the res/raw folder that means you cannot create a subfolder in it and that your images won't be compressed, so putting them without compress and considering they will be a lot of images then you app will be a bit heavy.

下面是两个环节,你可能会发现有益的:<一href="http://www.wiseandroid.com/post/2010/06/14/Android-Beginners-Intro-to-Resources-and-Assets.aspx"相对=nofollow> WiseAndroid 和提供了资源 - 开发指南

Here is two links that you might find helpfull: WiseAndroid and Providing Resources - Dev Guide

这篇关于/ Android的图像资产或资源/原材料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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