简体   繁体   English

如何使用在另一布局中的一个布局xml文件中声明的视图

[英]how to use views declared in one layout xml file in other layout

Respected All, I am newly working on android technology. 尊敬的所有人,我正在研究android技术。 I have use map view which is declared in another layout.I have to display in some part of may screen. 我使用了在另一种布局中声明的地图视图。我必须在五月屏幕的某些部分中显示。 can I use same map view or i have to create new mapview programmatically. 我可以使用相同的地图视图,还是必须以编程方式创建新的地图视图? In short i have to display map in some part of my screen. 简而言之,我必须在屏幕的某些部分显示地图。 How can i do it.. Thank You (Vikram Kadam) 我该怎么办..谢谢(维克拉姆·卡丹)

You need to use the tag <include> . 您需要使用标签<include> From the google documentation : 从Google文档中:

<com.android.launcher.Workspace
android:id="@+id/workspace"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
launcher:defaultScreen="1">

<include android:id="@+id/cell1" layout="@layout/workspace_screen" />
<include android:id="@+id/cell2" layout="@layout/workspace_screen" />
<include android:id="@+id/cell3" layout="@layout/workspace_screen" />

</com.android.launcher.Workspace>  

You can find a full explanation in the documentation. 您可以在文档中找到完整的说明

我将在XML文件中定义视图,然后每次需要时,都可以从XML文件中扩展视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何动态地将视图添加到已在xml布局中声明的RelativeLayout? - How to add views dynamically to a RelativeLayout already declared in the xml layout? 如何在布局xml中使用自定义视图 - how to use custom views in layout xml 如何使用布局XML文件中定义的视图作为模板来以编程方式创建视图 - How can i make use of views defined in layout XML file as template to create views programmatic way 如何以编程方式在视图内添加卡片视图,但使用 xml 中声明的布局? - How to add cardview programmatically inside view but use layout declared in xml? XML布局2个视图位于中心,顶部一个 - XML layout 2 views in centre, one at top 各种活动使用一种布局的相同视图-如何重构? - Various activities use same views from one layout - how to refactor? 如何使用约束布局使卡片视图始终在一个地方? - How to use constraint layout so the card views are always in one place? android - 在其他xml布局中添加一个xml布局 - android - add one xml layout in other xml layout 可以对所有活动使用一个menu.xml布局文件吗? - Is it ok to use one menu.xml layout file for all Activities? 如何在布局中包含 listView 以及布局中的其他视图 - How can I include listView in a layout with other views in the layout already
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM