layout.xml的目的是什么? [英] What is the purpose of layout.xml?

查看:146
本文介绍了layout.xml的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么人们使用 layout.xml S在其资源这样的:

Why do people use layout.xmls in their resources like:

<resources>
    <item name="main" type="layout">@layout/main_twopanes</item>
</resources>

虽然有替代资源使用特定的XML特定的配置?文件夹

while there are folders for alternative resources to use particular XML for particular configuration?

推荐答案

这是一个名为布局别名这里的链接:

要避免这种重复相同的文件为平板电脑和电视(和维护头痛由此产生),您可以使用别名文件。例如,您可以定义以下布局:

To avoid this duplication of the same file for tablets and TVs (and the maintenance headache resulting from it), you can use alias files. For example, you can define the following layouts:

和添加这两个文件:

RES /值-大/ layout.xml:

<resources>
    <item name="main" type="layout">@layout/main_twopanes</item>
</resources>

RES /值-sw600dp / layout.xml:

<resources>
    <item name="main" type="layout">@layout/main_twopanes</item>
</resources>

这些后两种文件具有相同的内容,但它们实际上并不限定的布局。他们只是建立主要是一个别名main_twopanes。由于这些文件都很大,sw600dp选择,它们应用到平板电脑和电视,无论Android版本(pre-3.2平板电脑和电视相匹配的大,和后3.2将匹配sw600dp)。

These latter two files have identical content, but they don’t actually define the layout. They merely set up main to be an alias to main_twopanes. Since these files have large and sw600dp selectors, they are applied to tablets and TVs regardless of Android version (pre-3.2 tablets and TVs match large, and post-3.2 will match sw600dp).

这篇关于layout.xml的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆