【发布时间】:2011-06-10 13:07:51
【问题描述】:
如何将一个 xml 数据包含到另一个 xml 数据中?
我的应用程序有一个标头 xml 文件,我想在我的特殊其他内容 xml 中使用它。有没有办法将标题包含到我的内容中?
【问题讨论】:
标签: android xml android-xml
如何将一个 xml 数据包含到另一个 xml 数据中?
我的应用程序有一个标头 xml 文件,我想在我的特殊其他内容 xml 中使用它。有没有办法将标题包含到我的内容中?
【问题讨论】:
标签: android xml android-xml
使用包含标签
<?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>
【讨论】:
您必须使用
<?xml version="1.0" encoding="utf-8"?>
<merge>
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="@drawable/image" / >
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:background="#AA000000"
android:textColor="#ffffffff"
android:text="Some Text" / >
</merge>
这是你的
【讨论】:
你应该使用
【讨论】: