Java代码
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);setContentView(R.layout.my);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.my_title);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);setContentView(R.layout.my);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.my_title);
my_title.xml:
Java代码
<?xmlversion="1.0"encoding="utf-8"?>
<RelativeLayoutandroid:id="@+id/header"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"android:layout_width="fill_parent"
android:background="#d4e9a9">
<ImageViewandroid:src="@drawable/jetpack"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:id="@+id/back"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"/>
<TextViewandroid:id="@+id/title"
android:layout_width="wrap_content"
android:gravity="center_vertical"
android:textSize="20px"
android:textColor="#ffffff"
android:layout_alignParentRight="true"
android:text="NewTitle"
android:background="#a5c639"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:padding="9dip"
android:layout_margin="5dip"/>
</RelativeLayout>
<?xmlversion="1.0"encoding="utf-8"?>
<RelativeLayoutandroid:id="@+id/header"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"android:layout_width="fill_parent"
android:background="#d4e9a9">
<ImageViewandroid:src="@drawable/jetpack"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:id="@+id/back"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"/>
<TextViewandroid:id="@+id/title"
android:layout_width="wrap_content"
android:gravity="center_vertical"
android:textSize="20px"
android:textColor="#ffffff"
android:layout_alignParentRight="true"
android:text="NewTitle"
android:background="#a5c639"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:padding="9dip"
android:layout_margin="5dip"/>
</RelativeLayout>
jetpack.xml:
Java代码
<?xmlversion="1.0"encoding="utf-8"?>
<selectorxmlns:android="http://schemas.android.com/apk/res/android">
<itemandroid:state_pressed="false"
android:drawable="@drawable/jetpack_normal"/>
<itemandroid:state_pressed="true"
android:drawable="@drawable/jetpack_pressed"/>
</selector>