Managing large number of resources in android /res/
folder is not an easy task.
I need to put all images inside drawable
or mipmap
folder. But I want to know are there any ways to store resources in some sort of folders? Like what we do for sources codes by adding packages and folder to keep them better organized and much readable and understandable?
As you may see this is a part of of my resources in drawable
folder and still there are much over there and it is so tackling to find them without referring the source code that refers to that drawable
.
You can use sourceSets
in your module's build.gradle
file to specify multiple resource directories, and then the build tools will merge them together. In those directories, you can add resources as you normally would in the res
directory.
https://developer.android.com/studio/write/add-resources#change_your_resource_directory https://developer.android.com/build/build-variants#sourcesets
For example, this config:
android {
...
sourceSets {
main.res.srcDirs = [
'src/main/res/folder1/',
'src/main/res/folder2/',
'src/main/res/folder3/',
]
}
}
Will result in this structure: