Android Studio: 新创建的目录不显示在文件夹视图中

我试图在/res 目录中创建一个新文件夹

我添加了一个新的目录

enter image description here

该文件夹不会出现在/res 文件夹中,即使它存在于查找程序中

enter image description here

案例和重点我试图再次添加文件夹,我得到一个消息告诉我它的存在。

enter image description here

如果你能建议我能做些什么来解决这个问题,我会很高兴的!

(是的,我已经重新启动了程序以及我的计算机)

94829 次浏览

Browse the actual folder structure in windows and you'll see the folder. Put the same resource file found in the normal drawable folder into this new directory. Then when you go back into Android Studio you'll now see 2 files under the NORMAL \res\drawable structure. Make sure you don't look for a subfolder in Android Studio called "drawable-sw600dp" because you won't find it other than in windows explorer. What you will find in Android Studio (after you copy the resource file) is a new resource file along with your original called "jenny-web.png (sw600dp)" or something similar. This same principle resolves the same error when working with other resources like layouts.

Turns out there is a selector at the top which, by default, is set to show Android. If you flick the toggle down to 'Packages' you can see your own packages.

enter image description here

In Android Studio you can add new directories by right clicking the resource folder in the Android view. (Don't get confused by the New Directory option.)

For example, if you want a new layout resource file and folder then right click layout and choose New > Layout resource file.

enter image description here

If you want a new layout-sw600dp for the activity_main.xml file then choose Smallest Screen Width from the list and click the >> button. Fill in the file name and width and click ok.

enter image description here

Android Studio will automatically create the layout-sw600dp directory and in the Android view you will have both layout files conveniently displayed next to each other.

enter image description here

It is a similar process for adding other resource directories and files (see my other example).

Clicking at TAB Android in top, select the perspective Project Files. Then u can see all folders of project. enter image description here

For Android Studio 3.0, those who are following https://developer.android.com/training/basics/supporting-devices/languages.html and have encountered the same issue as the one stated in this question, you can also do the following aside from the above answers which are helpful.

  1. Right click to the target folder (i.e. res folder) > New
  2. Choose Android Resource File
  3. Specify the file name, and in the Directory name field put the folder name you want to create or the existing folder you want to put the resource file.

enter image description here

After hitting OK, in the Project files dropdown, you will see the correct strucutre.

enter image description here

And in the Android dropdown, you will see it as part of the strings.xml under values folder.

enter image description here

This worked best for me. What I did was I right-clicked the 'app' directory and chose 'New' >> 'Android Resource File'. After that I filled in the File Name with 'strings'. Chose 'XML' as my resource type and my Directory Name was 'values-b+za+ZA'.

This created everything as I wanted it to, however, values-b+za+ZA, still didn't show in the Android view but it shows in the Package view. (The views you choose from the top dropdown.)

The difference this time is that in the Package view I can still see my new 'strings.xml' file and in the Android view I van also see the new 'strings.xml' file.

I guess android studio doesn't show custom directories in the Android view but creates like some kind of link to the true directory when working with it. I am not familiar with Android Studio at all but this did work for me. If there are more professional answers please feel free to correct me.

You most probably have the file named in Uppercase, Android Studio does not recognize file names in Uppercase, I had made this mistake a while back.

As the developer doc states:

be sure the Project window is open (select View > Tool Windows > Project) and the Android view is selected from the drop-down list at the top of that window.

You will then be able to see all relevant project files (including new ones) in a more efficient way.

Hope it helps someone.

This is odd but in my case i had to many underscores delimiters.

When i renamed yt_search_view (2 delimiters) to yt_searchview (1 delimiter), it appear in project view where it should be. It is probably a bug. My version is Android Studio 3.2.

Also, i notice that if i add a value folder to the layout folder, it also fix the issue.

Example:

layout_control_x
--layout
----top_panel.xml
--values  <--adding this empty folder fixed the problem

For complete information on how to add sub folder layouts check this.

Android 4.0

The Android view by default seems to conceal the duplicated resource type directories in the side panel.

If you want to view the duplicate resource type directories i.e. drawable for two different languages,

switch the view from "Android" to "Packages" or "Project" or "Project Files"

enter image description here