可在Android绘制的目录包含子目录? [英] Can the Android drawable directory contain subdirectories?
问题描述
在Android的SDK文档,所有与@可绘制/ my_image XML语法使用的例子直接针对存储在res /目录绘制在我的项目图片。
In the Android SDK documentation, all of the examples used with the @drawable/my_image xml syntax directly address images that are stored in the res/drawable directory in my project.
我想知道,如果它是明确不行的绘制目录中创建一个子目录。
I am wondering if it is explicitly not okay to create a sub directory within the drawable directory.
例如,如果我有以下的目录布局:
For example, if I had the following directory layout:
res/drawable
-- sandwiches
-- tunaOnRye.png
-- hamAndSwiss.png
-- drinks
-- coldOne.png
-- hotTea.png
我可以引用一个金枪鱼沙拉三明治的图像作为@可绘制/三明治/ tunaOnRye
Could I reference the image of a tuna salad sandwich as @drawable/sandwiches/tunaOnRye
还是我必须保持层级扁平的绘制目录。
Or do I have to keep the hierarchy flat in the drawable directory.
推荐答案
没有,资源机制不支持子文件夹中的绘制目录,所以是 - 你需要保持该层次结构扁平
No, the resources mechanism doesn't support subfolders in the drawable directory, so yes - you need to keep that hierarchy flat.
您显示的目录布局将导致没有被现有的图像。
The directory layout you showed would result in none of the images being available.
这是我自己的实验似乎有其内的所有项目的子文件夹,在水库内/绘制
文件夹,就会造成资源编译器失败 - $ P $数据的正确生成pventing的 R.java
文件。
From my own experiments it seems that having a subfolder with any items in it, within the res/drawable
folder, will cause the resource compiler to fail -- preventing the R.java
file from being generated correctly.
这篇关于可在Android绘制的目录包含子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!