views:

458

answers:

3

I want to create separate folders for my layouts, like this in my resource directory:

layout-land
layout-port

this is ok, but this:

layout-small-land
layout-small-port

or

layout-land-small
layout-port-small

Results in: 'Invalid resource directory name'

What gives?

A: 

You can specify the screen density instead of a size like Large or Small


Example:

layout-port-hdpi 
layout-port-ldpi 
layout-port-mdpi 
layout-port-nodpi 

layout-land-hdpi 
layout-land-ldpi 
layout-land-mdpi 
layout-land-nodpi 

More info in the following link:

http://developer.android.com/intl/fr/guide/topics/resources/resources-i18n.html#AlternateResources

For using Large, Medium, Small this is the way:

res/layout/my_layout.xml            // layout for normal screen size
res/layout-small/my_layout.xml      // layout for small screen size
res/layout-large/my_layout.xml      // layout for large screen size
res/layout-large-land/my_layout.xml // layout for large screen size in landscape mode
Donal Rafferty
then why is there screen orientaion options small/normal/large? BTW, my target is 1.6
codedeziner
`large` and `small` are valid resource set suffixes. See the third row (after the headers) of Table 2 on the page you linked to above.
CommonsWare
edited my answer there, they are all valid ways of using large or small etc in the folder name
Donal Rafferty
A: 

I haven't found anything else on the web that references this structure, but the following blog post shows an example where the author uses ldpi (and I'm sure mdpi and hdpi) instead of small, normal and large (as the android reference docs online would suggest). Have a look at the link below and maybe try that structure:

http://android.amberfog.com/?p=276

Rich
Halfway down the page here:http://developer.android.com/guide/practices/screens_support.htmlThere is an example using layout-large-land. Considering small/normal/large and port/land are options, I'm wondering why I can't use them.
codedeziner
A: 

layout-small-land and layout-small-port are the correct answers, and they compile just fine for me. Perhaps there is something else amiss in your directory structure.

CommonsWare
Turns out my app was targeted for 1.5 instead of 1.6. Once I changed the target, it compiled fine. Thanks for clarifying that the folder names should have worked for me.
codedeziner
Ah, yes, the `-small` and `-large` resource set suffixes did not show up until 1.6.
CommonsWare