页面之间的Andr​​oid XML常见元素?框架? [英] Android XML Common Elements between pages? Frames?

查看:137
本文介绍了页面之间的Andr​​oid XML常见元素?框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我剥皮一个应用程序,我想知道是否有保持共同的要素XML布局之间同样不复制相同的code周围所有的时间的一种方式。

I am skinning an app and I was wondering if there was a way to keep common elements the same between XML layouts without copying the same code around all the time.

比如说,我有一个页眉和页脚和背景,这将是大多数页面之间的相同。我可以做一个共同的XML包含页眉和页脚,只是加载单独的页面就像一个框里面它?

For instance, I have a header and footer and background that will be the same between most pages. Can I make a "common" xml containing the header and footer and just load the individual page like a frame inside of it?

我不知道我怎么会在XML中引用单独的页面。也许我可以在一个函数的onCreate改变从Java端的ID,尽管它看起来更多的工作,现在,如果我改变对未来的页眉和页脚的东西我也不会改变应用程序的每一个活动。

I'm not sure how I would reference that individual page within the XML. Maybe I could change an ID from the java side in an onCreate function, although it seems like more work now, if I changed something on the header and footer in the future I wouldn't have to change every Activity of the app.

感谢任何见解!

推荐答案

我想这就是你要找的inclue标记。例如:

I think it's the inclue tag you're looking for. Example:

<include layout="@layout/bar_header_top" />

这篇关于页面之间的Andr​​oid XML常见元素?框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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