Organize layout files in Android studio

Asked

Viewed 808 times

2

Following,

I have a project that will be huge in the end. currently I finished 1 module of a total of 4 modules and it is already full of layouts, etc. Follow an image just for you to be aware of how much file you have: inserir a descrição da imagem aqui

And still have a lot more layouts down yet...

Anyway, I would like to separate everything that is within res/layout within subfolders. It is possible?

1 answer

4


You can do this with Gradle from a look at this sample project

Here’s an example of the block in the file build.gradle of the example project, the subfolders are declared before.

sourceSets {
    main {
        res.srcDirs =
        [
                'src/main/res/layouts/layouts_category2',
                'src/main/res/layouts',
                'src/main/res'
        ]
    }
}

inserir a descrição da imagem aqui

I hope it helps you.

Source: stackoverflow.with

  • So I even saw this issue in the gringo stack, I didn’t get to open the guy’s project on github (I’m going to open it now) but after I did that, it started kicking ass in the java.... I’ll take a look at the guy’s design to see how he references this issue there

  • I use this example and everything works. Do the test there.

  • It’s just seen. 1 thing I did wrong. I tried using the "layout" folder after I realized that it creates another folder named layouts... I did the same and it worked. Thanks for the help!

  • How do I create the folders themselves? I did this in Gradle but the folders do not appear within layout

Browser other questions tagged

You are not signed in. Login or sign up in order to post.