The folders of an Android application follow a well-defined folder structure and names.
In sight "Android" does not fully reflect the hierarchy of existing folders in the project, only the "type" folders that make up this structure are displayed, for example folders with qualifiers are not listed.
Note that only one folder appears /res/mimpap, although there are folders /res/mipmap-hdpi, /res/mipmap-mdpi, etc..
Note that the folder names you mentioned, raw, anim, Animator, menu, color and xml, are listed because they are part of the list of defined names for Resources.
Although they can create other folders, they are not recognized as having Resources, you will not be able to reference the files in them, both in the code and in the xml, because an entry in the class is not generated R.
It is however possible to have these folders (the list) within another than just the src/main/res
, can create others as per ex: src/main/res2
. Use, in the file build.Gradle, the property res.srcDirs
in the block sourceSets
to indicate them as a Resources.
android{
....
....
sourceSets {
main {
res.srcDirs += ['src/main/res2']
}
}
}
To view all folders choose "Project" or "Packages" views".
--------------------------------------------------------------------------------------------------------
To create a subfolder in /res should right click on it, and choose new->Android Resource directory
In the Wizard open should choose the Resource intended and the qualifier to be applied, do not touch Directory Name.
The following example shows how to create a Resource of the kind layout and with the qualifier Portaint.
Usually it is not necessary to create these folders when creating a file of type "Android Resource file", if the folder does not exist it will be created.
In the Wizard which opens enter the name of the Resource, choose its type and qualifier, and the file will also be created (if it does not exist) the respective folder with the qualifier.
By image you want to create a directory under the folder /res, then use the option "Android Resource directory"
– ramaral
When using the Android option Resource directory also does not create a folder visible on the left side of the application. Unless I change the view mode however while programming I can’t also reference the folder...
– Judson Paiva
I think you can help him. http://stackoverflow.com/questions/29454427/new-directory-vs-new-folder-in-android-studio
– Reginaldo Rigo
Possible duplicate of How to create new folder in an Android Studio project
– viana
Before answering, I ask, why do you want to create a folder in Resources?
– Jorge B.
@seamusd is not duplicate, if you were attentive you would see that he has in his post the answer to the other question. The problem here is another.
– Jorge B.
@Jorgeb. Before realizing that Android already had well-defined default folder structures for everything I need, I tried to create specific folders for animation, for sound and for some photos for different parts of the project, was for this reason I wanted to create a new folder but with different default names...
– Judson Paiva
You can create these folders, the problem is that they are not recognized as having Resources, you will not be able to reference them, either in code or in xml, because no class entry is generated R
– ramaral
Very grateful @ramaral, as a conclusion so I am obliged even to use the predefined folders, to be able references later in XML as well as in Java code, right?
– Judson Paiva
The names layout, drawable, etc, yes. But they can be created in several Resources. Besides
src/main/res
can create other by ex:src/main/res2
. Use, in the file build.Gradle, the propertyres.srcDirs
in the blocksourceSets
to indicate them as Resources.– ramaral