Good day . I can’t find an answer to the question "Can I create additional directories in res in Android Studio, I have a lot of XML, I would like to scatter everything in my own folder, but how? I tried creating folders in layout and res, and nothing worked out. Thanks in advance !
- stackoverflow.com/a/22426467 or here it is in more detail - pavlofff
|
1 answer
In general, all the markup should be in the layout folder, but if you really want to separate them, then create any other folder in the res directory, for example, layout2 . Put your markup there and compile the project. All resource identifiers are stored in R.java , go to it and find the layout2 block with your markup names. Next, go to the activity and change the error line to
setContentView(R.layout2.yourLayout); I do not know what the studio will say to this, try it.
EDIT
You can create folders in the layout directory. To do this, create, for example, a folder a , then in build.gradle
sourceSets { main { res.srcDirs = [ 'src/main/res/layout/a', 'src/main/res/layout', 'src/main/res' ] } } And you need to write like this R.layout.a.yourLayout
|