Se puede definir la barra de navegación en la disposición header.xml separada de esta manera:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/header_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- 1px border top -->
<ImageView
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="@color/header_border_top" />
<!-- header with text and buttons -->
<RelativeLayout
android:layout_height="43dp"
android:layout_width="fill_parent"
android:background="@color/header_background">
<!-- left side -->
<LinearLayout
android:id="@+id/header_home_button_layout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_alignParentLeft="true">
<!-- home button -->
<ImageButton
android:id="@+id/header_home_button"
android:src="@drawable/header_btn_home"
android:onClick="onHomeClick" />
</LinearLayout>
<!-- header text -->
<TextView
android:id="@+id/header_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/app_name"
android:textSize="20dp"
android:textStyle="bold"/>
<!-- right side -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_alignParentRight="true">
<!-- back button -->
<ImageButton
android:id="@+id/header_back_button"
android:src="@drawable/header_btn_back"
android:onClick="onBackClick"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
<!-- 1px border bottom -->
<ImageView
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="@color/header_border_bottom" />
</LinearLayout>
Luego incluyen esta cabecera en la disposición de todas sus actividades:
<include
layout="@layout/header" />
Y asegúrese de que en todas sus clases extender clase padre que tiene los métodos enHomeClick y onBackClick ...
Gracias peceps :) En la respuesta anterior se me ha sugerido que use ActionBar. Tu sugerencia también es útil. Pero cuál es el mejor enfoque para esto. Sugerencia sincera por favor;) –