Android中應(yīng)用界面主題Theme使用方法和頁(yè)面定時(shí)跳轉(zhuǎn)應(yīng)用
更新時(shí)間:2013年06月14日 15:30:06 作者:
在Android SDK中內(nèi)置了下面的Theme,可以按標(biāo)題欄Title Bar和狀態(tài)欄Status Bar是否可見(jiàn)來(lái)分類(lèi),感興趣的朋友可以了解下哈
主題Theme就是用來(lái)設(shè)置界面UI風(fēng)格,可以設(shè)置整個(gè)應(yīng)用或者某個(gè)活動(dòng)Activity的界面風(fēng)格。在Android SDK中內(nèi)置了下面的Theme,可以按標(biāo)題欄Title Bar和狀態(tài)欄Status Bar是否可見(jiàn)來(lái)分類(lèi):
android:theme="@android:style/Theme.Dialog" 將一個(gè)Activity顯示為能話框模式
android:theme="@android:style/Theme.NoTitleBar" 不顯示應(yīng)用程序標(biāo)題欄
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不顯示應(yīng)用程序標(biāo)題欄,并全屏
android:theme="Theme.Light" 背景為白色
android:theme="Theme.Light.NoTitleBar" 白色背景并無(wú)標(biāo)題欄
android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,無(wú)標(biāo)題欄,全屏
android:theme="Theme.Black" 背景黑色
android:theme="Theme.Black.NoTitleBar" 黑色背景并無(wú)標(biāo)題欄
android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,無(wú)標(biāo)題欄,全屏
android:theme="Theme.Wallpaper" 用系統(tǒng)桌面為應(yīng)用程序背景
android:theme="Theme.Wallpaper.NoTitleBar" 用系統(tǒng)桌面為應(yīng)用程序背景,且無(wú)標(biāo)題欄
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系統(tǒng)桌面為應(yīng)用程序背景,無(wú)標(biāo)題欄,全屏
android:theme="Translucent" 半透明
android:theme="Theme.Translucent.NoTitleBar" 半透明、無(wú)標(biāo)題欄
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 半透明、無(wú)標(biāo)題欄、全屏
android:theme="Theme.Panel"
android:theme="Theme.Light.Panel"
android:theme="@android:style/Theme.Dialog" 將一個(gè)Activity顯示為能話框模式
android:theme="@android:style/Theme.NoTitleBar" 不顯示應(yīng)用程序標(biāo)題欄
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不顯示應(yīng)用程序標(biāo)題欄,并全屏
android:theme="Theme.Light" 背景為白色
android:theme="Theme.Light.NoTitleBar" 白色背景并無(wú)標(biāo)題欄
android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,無(wú)標(biāo)題欄,全屏
android:theme="Theme.Black" 背景黑色
android:theme="Theme.Black.NoTitleBar" 黑色背景并無(wú)標(biāo)題欄
android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,無(wú)標(biāo)題欄,全屏
android:theme="Theme.Wallpaper" 用系統(tǒng)桌面為應(yīng)用程序背景
android:theme="Theme.Wallpaper.NoTitleBar" 用系統(tǒng)桌面為應(yīng)用程序背景,且無(wú)標(biāo)題欄
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系統(tǒng)桌面為應(yīng)用程序背景,無(wú)標(biāo)題欄,全屏
android:theme="Translucent" 半透明
android:theme="Theme.Translucent.NoTitleBar" 半透明、無(wú)標(biāo)題欄
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 半透明、無(wú)標(biāo)題欄、全屏
android:theme="Theme.Panel"
android:theme="Theme.Light.Panel"
這些主題可以應(yīng)用到整個(gè)應(yīng)用Application范圍或者某個(gè)活動(dòng)Activity范圍中。
應(yīng)用Application范圍
在AndroidManifest.xml中的application節(jié)點(diǎn)中設(shè)置theme屬性,主題theme應(yīng)用到整個(gè)應(yīng)用程序中。
<application
Android:icon=”@drawable/icon”
Android:icon=”@string/app_name”
Android:icon=”@android:style/ Theme.Black.NoTitleBar”>
活動(dòng)Activity范圍
使用java代碼或者在AndroidManifest.xml中對(duì)活動(dòng)Activity的主題進(jìn)行設(shè)置,主題僅應(yīng)用到當(dāng)前活動(dòng)中。
在AndroidMainifest.xml設(shè)置方法:
<activity
android:name=“.About”
android:label=“@string/app_name”
android:theme=“@android:style/ Theme.Black.NoTitleBar” >
使用java代碼進(jìn)行設(shè)置,在當(dāng)前活動(dòng)Activity的onCreate中進(jìn)行設(shè)置:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Translucent_NoTitleBar);
setContentView(R.layout.main);
}
-------------跳轉(zhuǎn)---------------------
public void Start() {
new Thread() {
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Intent intent = new Intent();
intent.setClass(WelComeActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}.start();
}
---------為按鈕添按下效果-----------
imageButton1 = (ImageButton) findViewById(R.id.imageButton3);
imageButton1.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
// 更改為按下時(shí)的背景圖片
v.setBackgroundResource(R.drawable.menu_btn_f);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
// 改為抬起時(shí)的圖片
v.setBackgroundResource(R.drawable.menu_btn);
}
return false;
}
});
復(fù)制代碼 代碼如下:
android:theme="@android:style/Theme.Dialog" 將一個(gè)Activity顯示為能話框模式
android:theme="@android:style/Theme.NoTitleBar" 不顯示應(yīng)用程序標(biāo)題欄
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不顯示應(yīng)用程序標(biāo)題欄,并全屏
android:theme="Theme.Light" 背景為白色
android:theme="Theme.Light.NoTitleBar" 白色背景并無(wú)標(biāo)題欄
android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,無(wú)標(biāo)題欄,全屏
android:theme="Theme.Black" 背景黑色
android:theme="Theme.Black.NoTitleBar" 黑色背景并無(wú)標(biāo)題欄
android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,無(wú)標(biāo)題欄,全屏
android:theme="Theme.Wallpaper" 用系統(tǒng)桌面為應(yīng)用程序背景
android:theme="Theme.Wallpaper.NoTitleBar" 用系統(tǒng)桌面為應(yīng)用程序背景,且無(wú)標(biāo)題欄
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系統(tǒng)桌面為應(yīng)用程序背景,無(wú)標(biāo)題欄,全屏
android:theme="Translucent" 半透明
android:theme="Theme.Translucent.NoTitleBar" 半透明、無(wú)標(biāo)題欄
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 半透明、無(wú)標(biāo)題欄、全屏
android:theme="Theme.Panel"
android:theme="Theme.Light.Panel"
復(fù)制代碼 代碼如下:
android:theme="@android:style/Theme.Dialog" 將一個(gè)Activity顯示為能話框模式
android:theme="@android:style/Theme.NoTitleBar" 不顯示應(yīng)用程序標(biāo)題欄
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不顯示應(yīng)用程序標(biāo)題欄,并全屏
android:theme="Theme.Light" 背景為白色
android:theme="Theme.Light.NoTitleBar" 白色背景并無(wú)標(biāo)題欄
android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,無(wú)標(biāo)題欄,全屏
android:theme="Theme.Black" 背景黑色
android:theme="Theme.Black.NoTitleBar" 黑色背景并無(wú)標(biāo)題欄
android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,無(wú)標(biāo)題欄,全屏
android:theme="Theme.Wallpaper" 用系統(tǒng)桌面為應(yīng)用程序背景
android:theme="Theme.Wallpaper.NoTitleBar" 用系統(tǒng)桌面為應(yīng)用程序背景,且無(wú)標(biāo)題欄
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系統(tǒng)桌面為應(yīng)用程序背景,無(wú)標(biāo)題欄,全屏
android:theme="Translucent" 半透明
android:theme="Theme.Translucent.NoTitleBar" 半透明、無(wú)標(biāo)題欄
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 半透明、無(wú)標(biāo)題欄、全屏
android:theme="Theme.Panel"
android:theme="Theme.Light.Panel"
這些主題可以應(yīng)用到整個(gè)應(yīng)用Application范圍或者某個(gè)活動(dòng)Activity范圍中。
應(yīng)用Application范圍
在AndroidManifest.xml中的application節(jié)點(diǎn)中設(shè)置theme屬性,主題theme應(yīng)用到整個(gè)應(yīng)用程序中。
復(fù)制代碼 代碼如下:
<application
Android:icon=”@drawable/icon”
Android:icon=”@string/app_name”
Android:icon=”@android:style/ Theme.Black.NoTitleBar”>
活動(dòng)Activity范圍
使用java代碼或者在AndroidManifest.xml中對(duì)活動(dòng)Activity的主題進(jìn)行設(shè)置,主題僅應(yīng)用到當(dāng)前活動(dòng)中。
在AndroidMainifest.xml設(shè)置方法:
復(fù)制代碼 代碼如下:
<activity
android:name=“.About”
android:label=“@string/app_name”
android:theme=“@android:style/ Theme.Black.NoTitleBar” >
使用java代碼進(jìn)行設(shè)置,在當(dāng)前活動(dòng)Activity的onCreate中進(jìn)行設(shè)置:
復(fù)制代碼 代碼如下:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Translucent_NoTitleBar);
setContentView(R.layout.main);
}
-------------跳轉(zhuǎn)---------------------
復(fù)制代碼 代碼如下:
public void Start() {
new Thread() {
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Intent intent = new Intent();
intent.setClass(WelComeActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}.start();
}
---------為按鈕添按下效果-----------
復(fù)制代碼 代碼如下:
imageButton1 = (ImageButton) findViewById(R.id.imageButton3);
imageButton1.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
// 更改為按下時(shí)的背景圖片
v.setBackgroundResource(R.drawable.menu_btn_f);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
// 改為抬起時(shí)的圖片
v.setBackgroundResource(R.drawable.menu_btn);
}
return false;
}
});
您可能感興趣的文章:
- Android使用Intent的Action和Data屬性實(shí)現(xiàn)點(diǎn)擊按鈕跳轉(zhuǎn)到撥打電話和發(fā)送短信界面
- Android倒計(jì)時(shí)控件 Splash界面5秒自動(dòng)跳轉(zhuǎn)
- Android 6.0動(dòng)態(tài)權(quán)限及跳轉(zhuǎn)GPS設(shè)置界面的方法
- android 跳轉(zhuǎn)到應(yīng)用通知設(shè)置界面的示例
- Android如何通過(guò)scheme跳轉(zhuǎn)界面
- Android中檢查網(wǎng)絡(luò)連接狀態(tài)的變化無(wú)網(wǎng)絡(luò)時(shí)跳轉(zhuǎn)到設(shè)置界面
- Android 中按home鍵和跳轉(zhuǎn)到主界面的實(shí)例代碼
- Android跳轉(zhuǎn)到系統(tǒng)聯(lián)系人及撥號(hào)或短信界面
- Android編程使用Fragment界面向下跳轉(zhuǎn)并一級(jí)級(jí)返回的實(shí)現(xiàn)方法
- Android實(shí)現(xiàn)界面跳轉(zhuǎn)功能
相關(guān)文章
在Ubuntu下搭建Android開(kāi)發(fā)環(huán)境
對(duì)一個(gè)程序猿來(lái)說(shuō),裝好系統(tǒng)之后的第一件事,一定是搭建開(kāi)發(fā)環(huán)境,已經(jīng)安裝各種開(kāi)發(fā)工具,以便之后能方便順利地進(jìn)行程序的開(kāi)發(fā)。簡(jiǎn)單的介紹下在Ubuntu環(huán)境下搭建Android開(kāi)發(fā)環(huán)境,雖然基本上和在Windows下沒(méi)有太大差別,但有些細(xì)節(jié)上還是很值得注意的。2014-07-07
Android實(shí)現(xiàn)簡(jiǎn)單旋轉(zhuǎn)動(dòng)畫(huà)
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)簡(jiǎn)單旋轉(zhuǎn)動(dòng)畫(huà),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-07-07
Android開(kāi)發(fā)實(shí)現(xiàn)布局幀布局霓虹燈效果示例
這篇文章主要介紹了Android開(kāi)發(fā)實(shí)現(xiàn)布局幀布局霓虹燈效果,涉及Android界面布局、資源文件操作及屬性設(shè)置等相關(guān)技巧,需要的朋友可以參考下2019-04-04
Android實(shí)現(xiàn)在ServiceManager中加入自定義服務(wù)的方法詳解
這篇文章主要介紹了Android實(shí)現(xiàn)在ServiceManager中加入自定義服務(wù)的方法,結(jié)合實(shí)例形式分析了Android開(kāi)發(fā)中ServiceManager自定義服務(wù)的相關(guān)創(chuàng)建與使用方法,需要的朋友可以參考下2017-08-08
Android 動(dòng)畫(huà)之ScaleAnimation應(yīng)用詳解
本節(jié)講解ScaleAnimation 動(dòng)畫(huà)在應(yīng)用中的實(shí)現(xiàn),有需要的朋友可以參考下2012-12-12
android實(shí)現(xiàn)http中請(qǐng)求訪問(wèn)添加cookie的方法
這篇文章主要介紹了android實(shí)現(xiàn)http中請(qǐng)求訪問(wèn)添加cookie的方法,實(shí)例分析了兩種添加cookie的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10
詳解Android 檢測(cè)權(quán)限的三種寫(xiě)法
這篇文章主要介紹了詳解Android 檢測(cè)權(quán)限的三種寫(xiě)法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-10-10

