Right now, I\'m storing every XML layout file inside the \'res/layout\' folder, so it is feasible and simple to manage small projects, but when there is a case of large and
Top answers have several disadvantages: you have to add new layout paths, AS places new resources to res\layouts
folder instead of res\values
.
Combining several answers I wrote similar:
sourceSets {
main {
res.srcDirs =
[
'src/main/res',
file("src/main/res/layouts/").listFiles(),
'src/main/res/layouts'
]
}
}
I made folders with this article: http://alexzh.com/tutorials/how-to-store-layouts-in-different-folders-in-android-project/. In order to create subfolders you should use this menu: New > Folder > Res Folder.
UPDATE
After a couple of weeks I found that changes in resources are not noticed by Android Studio. So, some weird bugs appear. For instance, layouts continue to show old sizes, margins. Sometimes AS doesn't find new XML-files (especially during run-time). Sometimes it mixes view id
s (references to another XML-file). It's often required to press Build > Clean Project
or Build > Rebuild Project
. Read Rebuild required after changing xml layout files in Android Studio.