自定义实现功能图片如下:
?
?
?
package com.easyway.titlebar;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
/**
* 自定义窗体标签的样式表格式的使用
* 1.设置window标题信息
* requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); //声明使用自定义标题
* setContentView(R.layout.main);
* //设置窗体样式
* getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);//自定义布局赋值
* 2.在对应的Activity中添加相关的 android:theme="@style/test"管理对应的样式
*
*
* android:theme="@style/test">
*
*
*
*
*
*
* @author longgangbai
*
*/
public class AndroidTitleBarActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); //声明使用自定义标题
setContentView(R.layout.main);
//设置窗体样式
getWindow().setFeatureInt(
Window.FEATURE_CUSTOM_TITLE, //设置此样式为自定义样式
R.layout.title //设置对应的布局
);//自定义布局赋值
}
}
?
?
strings.xml
Hello World, AndroidTitleBarActivity!
AndroidTitleBar
@drawable/logo
40dp
@style/CustomWindowTitleBackground
?
?
title.xml
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:src="@drawable/qq" />
android:layout_centerInParent="true"
android:layout_height="wrap_content"
android:text="自定义标题栏" />
?
?
?
package="com.easyway.titlebar"
android:versionCode="1"
android:versionName="1.0" >
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
android:label="@string/app_name"
android:theme="@style/test"
android:name=".AndroidTitleBarActivity" >
?
AndroidTitleBar.rar (57.4 KB)
下载次数: 1