Android布局加载子布局
我想让我的 xml 布局更加模块化,因为这个布局将非常复杂!
我希望一些片段位于它们自己的 xml 文件中。我如何在主 XML 文件中正确引用它们。
例如,
假设我有一个
<relative layout>
<linear layout>
<relative layout>
<frame layout>
<relative layout>
<linear layout>
有一个非常复杂的子级,其中包含包含按钮和滚动视图的列,其中包含列表视图。
我想在它自己的 XML 中开发框架布局,然后仅在我的主文档中引用该 xml 文档,
其语法是什么样的?它仅与分配给我的主 XML 中的 的 ID 有关吗?
I want to make my xml layout more modular because this one is going to be pretty intricate!
I want some pieces to be in their own xml files. How would I reference them properly in the main XML file.
for instance
Lets say I have a
<relative layout>
<linear layout>
<relative layout>
<frame layout>
<relative layout>
<linear layout>
but the <frame layout>
has a very complex child, with columns containing buttons and scrollviews which contain listviews.
I would like to develop the frame layout in its own XML and then merely reference that xml document within my main one
what would the syntax for that look like? is it solely related to the ID that assign to <frame layout>
within my main XML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文章布局技巧:合并布局 描述布局 xml 文件的
和
标记。使用
您可以引用其他布局,
可以帮助您使视图层次结构更加扁平。The article Layout Tricks: Merging Layouts describes the
<merge>
and the<include>
tag for layout xml files.With
<include>
you can reference an other layout and<merge>
can help to make your view hierarchy flatter.