很简单,这是我的 header.xml
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button_up"
android:layout_width="48dp"
android:layout_height="48dp"
android:drawableTop="@drawable/undo" />
<TextView
android:id="@+id/path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="4dp"
android:textSize="18sp"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_toRightOf="@+id/button_up"
android:layout_toLeftOf="@+id/button_play"
android:text="@string/path" />
<Button
android:id="@+id/button_play"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_toLeftOf="@+id/button_settings"
android:drawableTop="@drawable/play" />
<Button
android:id="@+id/button_settings"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentRight="true"
android:drawableTop="@drawable/settings" />
</RelativeLayout>
我将它包含在 activity_main.xml 的前面,这是我的应用程序的默认 xml。包含后有分隔线,下一个是我的列表视图白色项目。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:padding="4dp"
android:background="@color/gray_light"
android:orientation="vertical" >
<include layout="@layout/header" />
<View
android:id="@+id/separator_up"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginTop="2dp"
android:background="@color/blue_light" />
<include layout="@layout/list" />
</LinearLayout>