1

I have a fairly complex android app, the contents of the 'layout' folder is becoming increasingly large. I've tried to organise the individual layout xml files into sub folders e.g. layout/dialog/, layout/activity/, layout/views/ etc. This doesn't seem to work, the content of the folders in not parsed into the R. class.

Is there a way to do this?

Thanks!

Narendra
  • 1,868
  • 6
  • 25
  • 39

4 Answers4

2

Short answer is no, subfolders are not supported. You probably just need to get clever with naming the files. See this question: Can the Android drawable directory contain subdirectories?

Community
  • 1
  • 1
Steve Blackwell
  • 5,904
  • 32
  • 49
2

Resource directories should be flat. So, if your intention is to have layout/dialog, layout/activity/, layout/views/, etc. you should go with layout/dialog_whatever, layout/activity_whatever and layout/views_whatever, which gives you more or less the same organization.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
2

No, resource directories doesn't support sub directories structures, Because it all about indexing in your R.java files,

You have to give naming conversion for your files, like, layout/activity_..

user370305
  • 108,599
  • 23
  • 164
  • 151
0

If you have more xml layout in your app then you have to give the proper naming convention as the xml use in the perticular activity.

as like if your activities are like activity1, activity2 and the xml in that activities are dialog1.xml, dialog2.xml, main1.xml, main2.xml, button1.xml, button2.xml, view1.xml, view2.xml ...etc

Then use that xml layout with naming convention as like:

layout\activity1_dialog1.xml

layout\activity1_main1.xml

layout\activity1_button1.xml

layout\activity1_view1.xml

layout\activity2_dialog2.xml

layout\activity2_main2.xml

layout\activity2_button2.xml

layout\activity2_view2.xml

Hope you got my point. It will realy help you to manage the xml layout as i am doing same thing.

Enjoy. :)

Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188