When creating folder inside the folder /res it is not visible in the left panel

Asked

Viewed 2,661 times

4

When I put the name of the new folder and press Enter, that same folder does not appear on the left side of the Project nor can I reference its path.

The strange thing is that if I put the folder name as raw, anim, Animator, menu, color, xml this appears, already other name does not.
So little can I create hierarchy between folders.

Criar uma nova Pasta ou Diretório no Android Studio

  • By image you want to create a directory under the folder /res, then use the option "Android Resource directory"

  • When using the Android option Resource directory also does not create a folder visible on the left side of the application. Unless I change the view mode however while programming I can’t also reference the folder...

  • I think you can help him. http://stackoverflow.com/questions/29454427/new-directory-vs-new-folder-in-android-studio

  • 4
  • Before answering, I ask, why do you want to create a folder in Resources?

  • 1

    @seamusd is not duplicate, if you were attentive you would see that he has in his post the answer to the other question. The problem here is another.

  • @Jorgeb. Before realizing that Android already had well-defined default folder structures for everything I need, I tried to create specific folders for animation, for sound and for some photos for different parts of the project, was for this reason I wanted to create a new folder but with different default names...

  • You can create these folders, the problem is that they are not recognized as having Resources, you will not be able to reference them, either in code or in xml, because no class entry is generated R

  • Very grateful @ramaral, as a conclusion so I am obliged even to use the predefined folders, to be able references later in XML as well as in Java code, right?

  • The names layout, drawable, etc, yes. But they can be created in several Resources. Besides src/main/res can create other by ex: src/main/res2. Use, in the file build.Gradle, the property res.srcDirs in the block sourceSets to indicate them as Resources.

Show 5 more comments

4 answers

5

The folders of an Android application follow a well-defined folder structure and names.

In sight "Android" does not fully reflect the hierarchy of existing folders in the project, only the "type" folders that make up this structure are displayed, for example folders with qualifiers are not listed.

Note that only one folder appears /res/mimpap, although there are folders /res/mipmap-hdpi, /res/mipmap-mdpi, etc..

Note that the folder names you mentioned, raw, anim, Animator, menu, color and xml, are listed because they are part of the list of defined names for Resources.

Although they can create other folders, they are not recognized as having Resources, you will not be able to reference the files in them, both in the code and in the xml, because an entry in the class is not generated R.

It is however possible to have these folders (the list) within another than just the src/main/res, can create others as per ex: src/main/res2. Use, in the file build.Gradle, the property res.srcDirs in the block sourceSets to indicate them as a Resources.

android{

    ....
    ....
    sourceSets {
        main {
            res.srcDirs += ['src/main/res2']
        }
    }
}

To view all folders choose "Project" or "Packages" views".

--------------------------------------------------------------------------------------------------------

To create a subfolder in /res should right click on it, and choose new->Android Resource directory

inserir a descrição da imagem aqui

In the Wizard open should choose the Resource intended and the qualifier to be applied, do not touch Directory Name.

The following example shows how to create a Resource of the kind layout and with the qualifier Portaint.

inserir a descrição da imagem aqui

Usually it is not necessary to create these folders when creating a file of type "Android Resource file", if the folder does not exist it will be created.

inserir a descrição da imagem aqui

In the Wizard which opens enter the name of the Resource, choose its type and qualifier, and the file will also be created (if it does not exist) the respective folder with the qualifier.

inserir a descrição da imagem aqui

4

I suggest you change the visualization mode of your project. Test using Project Files mode... in this mode you have access to the file structure, by the Studio file manager.

t+

captura de tela studio...

3

The RES folder does not allow creating sub-folders. You can use a plugin to simulate folders in the RES based on file names.

Name: Android File Grouping

To add to the IDE, press Ctrl+alt+s and go to Plugins and search for Android File Grouping. To use, click the layout folder with the right and go to Group (you have to go to "Project view mode")

inserir a descrição da imagem aqui

-1

Good evening guys all right? Answering the first question the folder created does not appear even, try this way worked for me. CLICK THE ARROW OF THE FOLDER RES/ THEN IN THE BAR THAT SHOWS EACH OPEN DIRECTORY CLICK RES/ AGAIN THAT YOUR CREATED FOLDER WILL BE THERE AI IS JUST SELECT IT, I HOPE I HAVE HELPED.inserir a descrição da imagem aqui

Browser other questions tagged

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