10

I am developing an Android app and I currently have about 8 layout xml files in the layout folder. The need for organizing this folder is increasing with each additional layout resource file. However, when I create a folder inside of the layout folder and move a resource to it via the refactor operation, it breaks my project.

For example, my resource is being refernced here:

setContentView(R.layout.login);

After moving the login.xml file to a newly created folder called "test", it breaks my build.

If I update the reference to:

setContentView(R.layout.test.login);

It still doesn't compile.

Any help would be greatly appreciated.

Adinia
  • 3,722
  • 5
  • 40
  • 58
Byrolong
  • 151
  • 1
  • 5
  • Possible duplicate of [Can the Android Layout folder contain subfolders?](http://stackoverflow.com/questions/4930398/can-the-android-layout-folder-contain-subfolders) – Code-Apprentice Nov 22 '16 at 11:32

2 Answers2

11

Sub folders in resources is not currently supported. I think everyone who read this should put a star on the issue.

xandy
  • 27,357
  • 8
  • 59
  • 64
  • 2
    Now, according to the [article](https://code.google.com/p/android/issues/detail?id=2018#c64) it appears that if you use the Gradle build system you **can** have sub directories. However, Google will **not** be implementing this for other build systems (e.g. Ant, etc.). Relevant Comment: "Marking this as released. This is largely possible in the Gradle build system as it exists today, and we won't be implementing this for other build systems" – Forrest Bice Jan 25 '14 at 02:59
0

you need to follow the naming convention You cannot create a folder inside a layout. if you want to create a folder, create inside a res folder. ex:- layout-large,layout-small etc

Tarun Tak
  • 421
  • 1
  • 5
  • 12