Can I use additional directories for grouping Android resources -


creating of large android project lead numerous layout files in res folder. can group them creating subfolders? is possible in android?

for example have now:

res/     /layout/            /some large list there 

and wanted achieve:

res/    /layout/       /subfolder1/          /layout1.xml          /view1.xml          ......       /subfolder2          /another_layout.xml          /another_view.xml 

i tried got error of compilation. appreciate help.

the answer yes, but if you're using android studio , gradle build system.

btw: there's thread on code.google.com discussing issue (issue 2018: r.java should recognize resources in sub-directories).
has been closed project member following statement:

marking released. largely possible in gradle build system exists today, , won't implementing other build systems.

so how can realise in android studio? here's how:

  1. right click on layout-folder --> new --> directory --> name e.g. subfolder1
  2. right click on subfolder1 --> new --> android resource directory (this may not selectable in first place, see notes below)
  3. name layout, layout-land, layout-sw600dp or whatever want needs valid layout resource folder
  4. create more subfolders or layout-folders in sub-dirs
  5. modify build.gradle file this:

android {     // other stuff     sourcesets {         main {             res.srcdirs =                     [                       '/src/main/res/layout/subfolder1',                       '/src/main/res/layout/subfolder2',                       '/src/main/res'                     ]         }     } } 

result this:

sub directories in layout folder

some things note:

  • you may need sync gradle in between, otherwise won't able create "android resource directory in subfolder
  • if you're using android-view in android studio won't seeing subfolders. consider bug fixed, hopefully.
  • this works drawables , every other resource type well

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -