别名具有相同名称的只是不同的屏幕预选赛布局资源 [英] Aliasing a layout resource with same name just different screen qualifier
问题描述
我有一个布局,是纵向和横向的不同;然而,在平板电脑上(如真正的大屏幕,XLARGE布局预选赛)我想只用肖像版本两个方向。
I have a layout that is different for portrait and landscape; however on tablets (e.g. really big screen, xlarge layout qualifier) I want to use only the portrait version for both orientations.
/res/layout/abc.xml
/res/layout/abc.xml
/res/layout-land/abc.xml
/res/layout-land/abc.xml
/res/layout-xlarge/abc.xml
/res/layout-xlarge/abc.xml
由于第一个和最后的布局是相同的,我在考虑使用别名。但我不能从<一弄清楚href="http://developer.android.com/guide/topics/resources/providing-resources.html#AliasResources">Android文档如何引用预选赛的具体布局,我的发言......
Since the first and last layouts are identical, I was thinking of using an alias. But I can't figure out from the Android docs how to reference a qualifier specific layout in my statement...
想法?
推荐答案
我恰好有战斗!同样的问题,终于找到了一个解决方案,因此,即使问题很老了,也许有人觉得它有用
I was fighting with exactly! same problem and finally found a solution, so even if question is quite old, maybe someone find it useful
-
把纵向布局成
/res/layout/abc.xml
(你已经拥有它)
把景观布置成 /res/layout/abc_land.xml
创建文件 layout.xml
与内容
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="abc" type="layout">@layout/abc_land</item>
</resources>
将此文件复制到你的 / RES /值陆/
和 / RES /值-XLARGE /
目录
重要的是,你的 layout.xml
文件包含引用改善(景观)文件 abc_land.xml
,这也存储在布局
目录和文件也正在值-X
目录,而不是布局-X
键。
Important is, that your layout.xml
file contain reference to improved (landscape) file abc_land.xml
, that is stored also in layout
directory and also files are under values-x
directories, not layout-x
once.
此外,我试图把到布局目录中的两个文件 abc_land.xml
和 abc_port.xml
,并在其上创建从 / RES /值陆/
, / RES /值端口/
也 / RES /值-XLARGE /
目录,并似乎工作,所以它也是有用的解决方案,使布局中的一些命令!
Also I tried to put into layout directory two files abc_land.xml
and abc_port.xml
and create on them alias from /res/values-land/
, /res/values-port/
and also /res/values-xlarge/
directories, and seems to work, so it's also usable solution to make in layouts some "order"!
这篇关于别名具有相同名称的只是不同的屏幕预选赛布局资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!