Android:将一个 xml 包含到另一个 xml 中 [英] Android: include a xml into an other xml

查看:42
本文介绍了Android:将一个 xml 包含到另一个 xml 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将一个xml数据包含到另一个xml数据中?

How to include a xml data into an other xml data?

我的应用程序有一个标题 xml 文件,我想在我的其他特殊内容 xml 中使用它.有没有办法将标题包含在我的内容中?

I have a header xml-file for my application which I want to use in my special other content xmls. Is there a ways to include the header into my content?

推荐答案

使用include标签

use include tag

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"     
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
 >
  <!-- Header -->
  <include
    android:id="@+id/container_header_lyt"  
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:layout_above=...
    android:layout_toLeftOf=...
    layout="@layout/header_logo_lyt" //Name of the xml layout file you want to include
    />     

...

</RelativeLayout>

这篇关于Android:将一个 xml 包含到另一个 xml 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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