什么是工具:布局片段xml文件?片段、布局、文件、工具

2023-09-06 01:42:42 作者:死性不改i

我开始基于使用ADT Eclipse的主/从流程模板创建一个新的Andr​​oid应用程序。该模板创建两个活动,一个主片段和,以适合小和大屏幕的细节片段。

I started a new Android Application based on master/detail flow template using ADT Eclipse. This template creates two activities, a master fragment and a detail fragment in order to fit small and larger screens.

我注意到了 activity_item_list.xml 文件的工具:布局属性:

I noticed the activity_item_list.xml file has the tools:layout attribute:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/item_list"
    android:name="com.example.fragmenttwopanel.ItemListFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    tools:context=".ItemListActivity"
    tools:layout="@android:layout/list_content" />

我试图删除属性和应用程序运行在相同的方式,但在ADT的图形布局选项卡,留言问我:

I tried to delete the attribute and the app runs in the same way but in the graphical layout tab of ADT, a message ask me for:

从片段布局上下文菜单中挑preVIEW布局

pick preview layout from the "Fragment Layout" context menu

其目的是什么?难道仅仅是为preVIEW在图形布局?

What is its purpose? Is it just for preview in graphical layout?

推荐答案

这是使用的IDE工具的命名空间。运行的装置(或仿真)上的应用程序,这是没有必要的。在另一方面,如果你离开他们,Android将忽略它们当应用程序在设备上运行。

This is a namespace used by the IDE tools. This is not needed to run the application on a device (or emulator). On the other hand, if you leave them, Android will ignore them when the application is running on a device.

这是使用如皮棉和图形布局选项卡。

This is used by e.g. lint and graphical layout tab.

您可以检查它是如何使用不起毛的位置:http://developer.android.com/tools/debugging/improving-w-lint.html在部分配置皮棉检查XML。

You can check how it's used by lint here: http://developer.android.com/tools/debugging/improving-w-lint.html in section Configuring lint checking in XML.