Android布局加载子布局

发布于 2024-11-19 15:22:38 字数 488 浏览 6 评论 0原文

我想让我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微凉 2024-11-26 15:22:38

文章布局技巧:合并布局 描述布局 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文