Good day! As far as I know, resource files can be grouped by directories only in the assets directory, in other resource directories all files should be on the same level. Are there any opportunities for a more or less convenient way to manage resources?

  • 2
    You can give them grouped consoles. For example, first_screen_image_button - Vladyslav Matviienko
  • @metalurgus currently doing so, I thought maybe I missed some feature. - x555xx

3 answers 3

The hierarchy of folders and files in the android project has a strictly defined structure and cannot be changed.

In Android Studio, a new project tree view mode has been introduced - Android (installed by default) instead of the Project mode in IntelliJ IDEA, in which some attempts have been made to group files in the project tree, so instead of a heap of folders: drawable-hdpi / , draweble-xhdpi / etc , one drawable / folder with files inside it: image.png (hdpi) , image.png (xhdpi) and so on. Similarly for other resource folders. Naturally, this is only a view in the studio tree and does not affect the actual folder structure of the project. This is where the standard features end.

There is a plugin for the Android File Grouping studio , which creates an additional virtual separation of files in a project into subfolders according to the principle that, for example, the file name: activity_main.xml - the plugin converts the presentation so that in the layout folder / there will be a virtual folder called activity / , and there is a main.xml file in it, respectively, all files that begin with activity_ will be in the same virtual folder, starting with another line, for example, fragment_ * will be in the folder fragment / and so on. Naturally, no changes are made to the real structure of the project directories.

  • Thanks for the detailed response, I already got acquainted with the display modes, it is much more convenient with them. - x555xx

Perhaps with the help of Gradle. In the file app.gradle you need to create folders:

 sourceSets { main { res.srcDirs = [ 'src/main/res-main', 'src/main/res-screen/about', 'src/main/res-screen/chat', 'src/main/res-screen/event-detail', 'src/main/res-screen/event-list', 'src/main/res-screen/home', 'src/main/res-screen/login', ] } } 

More details can be found in the article: On Habré

    There is an Android File Grouping Plugin plugin: https://github.com/dmytrodanylyk/folding-plugin

    But there is a possibility that it may not work, because The last update of the plugin was 4 years ago.

    • this plugin is mentioned in my answer) - pavlofff
    • @pavlofff it was not originally) now you of course changed and added)) - Famous
    • yes, but nevertheless added before your father) You asked a question on this topic and I remembered that I answered a similar question, at the same time I added a plugin. While writing, you have already deleted the question .. in general, something like this ... - pavlofff 1:54 pm
    • @pavlofff well, then sorry. I just laid out the post first, then decided to look for similar questions on a stack and found it. And then I decided to delete my post. - Famous