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:
- right click on layout-folder --> new --> directory --> name e.g. subfolder1
- right click on subfolder1 --> new --> android resource directory (this may not selectable in first place, see notes below)
- name layout, layout-land, layout-sw600dp or whatever want needs valid layout resource folder
- create more subfolders or layout-folders in sub-dirs
- 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:
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
Post a Comment