Layout XML folder is missing in Android Studio
Asked Answered
B

5

5

Problem:

enter image description here

layout XML folder is missing?
How to add it?

Billhook answered 9/1, 2018 at 12:54 Comment(2)
Create xml file from res(right click) > new > add android resource file > enter file name, select resource type(Layout).Gantz
This is the correct way to add a layout folder: https://mcmap.net/q/930782/-can-39-t-create-layout-folder-in-android-studio-by-new-android-resource-directory-error-enter-or-select-a-qualifierFrailty
K
13

If the folder isn't there or wasn't added automatically when you created the project, you need to add it to your project in the following way:

  • Right-click on the res folder
  • Select New -> Android Resource Directory from the menu that opens
  • Select Resource type to be layout from the popup that opens
  • Click ok

Now you have added your layout folder, so you can now start adding XML files to this folder by the following steps:

  • Right-click on the layout folder
  • Select New -> Layout Resource File from the menu that opens
  • Enter your new file name
  • Click ok

Now you have a new XML file that you can use in any activity or fragment.

Kipper answered 9/1, 2018 at 13:26 Comment(0)
E
1

If we select "Empty Views Activity" while creating new project we'll get the layouts folder. If you choose "Empty activity", the layout folder will not be generated.

What's the difference between "Empty Views Activity" and "Empty Activity"? Which one should you select while creating a new project?

Select "Empty Views Activity" if you want to develop the app using JAVA. Select "Empty Activity" if you want to develop using Kotlin Language(which is now the default programming language for Android development by Google).

Equinoctial answered 15/10 at 8:9 Comment(0)
W
0

In my case, there was no xml file at all, thanks to the answer above I created my activity_main.xml file by myself, but then, I created some new fragments and there was no xml files for those also.

I was just like, "think simple". Then I invalidated caches and restarted my Android Studio, all xml files were there. Funny but that's how it works in my scenario. I hope it helps someone.

Willock answered 31/7, 2023 at 7:20 Comment(0)
S
0

when create new project select a "empty views activity". if you select empty "activity project" not show layout folder.

Sea answered 30/4 at 16:37 Comment(0)
C
-2

After open the layout resource file and which new file name, can be typed

Costanza answered 20/11, 2022 at 15:27 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Avalokitesvara

© 2022 - 2024 — McMap. All rights reserved.