Android定制Title
1. 先确定Title的具体Xml文件:
<?xmlversion="1.0"encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="abcdefg" ></TextView> <ImageButton android:id="@+id/refresh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_alignParentRight="true" android:background="#00000000" android:src="@drawable/refresh_btn_normal" ></ImageButton> </RelativeLayout>
|
2.在Strings.xml中加入标题样式:
3.在Mainfest.xml中对应的activity中添加定义的标题主题
<activity android:theme="@style/test" android:name="com.example.Switch.Device_set"> </activity> |
//声明使用自定义布局 requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.device_set); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
|