安卓:包括XML转换为其他XML转换为、XML

2023-09-12 10:30:10 作者:失败乃成功之母

如何包含XML数据转换成其他XML数据

How to include a xml data into an other xml data

我有一个头的XML文件为我的应用程序至极,我想在我的特殊的其他内容XMLS使用 有没有方法可以包括头部到我的内容?

i have a header xml-file for my application wich i want to use in my special other content xmls is there a ways to include the header into my content?

推荐答案

使用包括标签

<?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>