質問

XMLデータを他のXMLデータに含める方法

私は私の特別な他のコンテンツで使用したいので、アプリケーションのためにヘッダーXMLファイルを持っていますXMLS私のコンテンツにヘッダーを含める方法はありますか?

役に立ちましたか?

解決

使用するタグを含みます

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

他のヒント

<merge>タグで「ボディ」XMLレイアウトを宣言する必要があります。

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

これはあなたの<cluding>タグのコンテンツです

<cluding>タグを使用する必要があります: レイアウトの再利用

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top