Can AndroidStudio layout resource folders be classified?

The layout files of the whole project are stored in the layout folder of

Android Studio. Is there any way to store them separately? All huddled together in one folder completely confuses which file belongs to which function module.
my current folder is as follows:


Yes, you can create a folder according to the module in the original res/layout directory, and then create a new layout folder under each folder and store files in this layout.

then add the following code to the build.gradle file:

    def listSubFile = {
        def resFolder = 'src/main/res/layout'
        def files = file(resFolder).listFiles()
        def folders = []
        files.each {
            item -> folders.add(item.absolutePath)
        }
        folders.add(file(resFolder).parentFile.absolutePath)
        return folders
    }

    sourceSets {
        main {
            res.srcDirs = listSubFile()
        }
    }
    

for more information, please take a look at this article http://www.newbieprogrammer.c.

.
Menu