You will need to keep one xml for header: (say, header.xml)
header.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/headerlayout"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:gravity="top"
android:padding="0dip"
android:orientation="vertical"
android:textColor="@color/black"
>
<!-- Header content -->
</LinearLayout>
Now, in all your activity's xml, include that xml as follows:
activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/body_bkgd" >
<include
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
layout="@layout/header" />
<!-- other views -->
</RelativeLayout>
Hope it helps.
Edit:
For making header.xml as you want, you need to learn how to design your layouts.
Simple would be:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/headerlayout"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:gravity="top"
android:padding="0dip"
android:orientation="vertical"
android:textColor="@color/black"
>
<ImageView
android:id="@+id/firstimg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/yourimage" />
<Button
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alert Details"
android:background="#f60000"
android:textColor="#ffffff" />
</LinearLayout>