java 如何创建 layout-small-land 文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2402639/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create layout-small-land folder?
提问by codedeziner
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?
是什么赋予了?
采纳答案by CommonsWare
layout-small-landand layout-small-portare the correct answers, and they compile just fine for me. Perhaps there is something else amiss in your directory structure.
layout-small-land并且layout-small-port是正确的答案,它们对我来说编译得很好。也许您的目录结构中还有其他问题。
回答by Donal Rafferty
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:
以下链接中的更多信息:
https://developer.android.com/guide/topics/resources/resources-i18n.html#AlternateResources
https://developer.android.com/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
回答by Erik
It will give you a "invalid resource error"until the folder is empty. If you fill it with the .xmlfiles (they have to match exactly in every layout-<qualifier>folders) it gives you no error.
它会给你一个"invalid resource error"直到文件夹为空。如果你用.xml文件填充它(它们必须在每个layout-<qualifier>文件夹中完全匹配),它不会给你任何错误。
EG:
例如:
layout-port
--> mainscreen.xml
layout-large-port
--> mainscreen.xml
布局端口
--> 主屏幕.xml
布局大端口
--> 主屏幕.xml
it's ok
没关系
回答by Rich
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:
我还没有在网上找到任何其他引用此结构的内容,但以下博客文章显示了一个示例,其中作者使用 ldpi(并且我确定 mdpi 和 hdpi)而不是 small、normal 和 large(作为 android 参考)在线文档会建议)。看看下面的链接,也许可以尝试这种结构:

