1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > java怎么设置窗体标题_Android窗体自定义标题栏

java怎么设置窗体标题_Android窗体自定义标题栏

时间:2021-01-03 22:44:09

相关推荐

java怎么设置窗体标题_Android窗体自定义标题栏

自定义实现功能图片如下:

?

?

?

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。