Android中實現全屏、無標題欄的兩種辦法(另附Android系統自帶樣式的解釋)(轉)


實現全屏無標題欄:

1.在xml文件中進行配置

AndroidManifest.xml中,找到需要全屏或設置成無標題欄的Activity,在該Activity進行如下配置即可。

實現全屏效果:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"  

實現無標題欄(但有系統自帶的任務欄):

android:theme="@android:style/Theme.NoTitleBar"  

 

2.編寫代碼設置
在程序中編寫代碼進行設置,只需在onCreate()方法中加入如下代碼即可

Coding: // Full Screen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
    WindowManager.LayoutParams.FLAG_FULLSCREEN);

// No Titlebar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);

 

附:Android系統自帶樣式

android:theme="@android:style/Theme.Dialog" 將一個Activity顯示為對話框模式 
android:theme="@android:style/Theme.NoTitleBar" 不顯示應用程序標題欄 
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不顯示應用程序標題欄,並全屏 
android:theme="Theme.Light" 背景為白色 
android:theme="Theme.Light.NoTitleBar" 白色背景並無標題欄 
android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,無標題欄,全屏 
android:theme="Theme.Black" 背景黑色 
android:theme="Theme.Black.NoTitleBar" 黑色背景並無標題欄 
android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,無標題欄,全屏 
android:theme="Theme.Wallpaper" 用系統桌面為應用程序背景 
android:theme="Theme.Wallpaper.NoTitleBar" 用系統桌面為應用程序背景,且無標題欄 
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系統桌面為應用程序背景,無標題欄,全屏 
android:theme="Translucent"  透明背景
android:theme="Theme.Translucent.NoTitleBar"  透明背景並無標題
android:theme="Theme.Translucent.NoTitleBar.Fullscreen"  透明背景並無標題,全屏
android:theme="Theme.Panel"   面板風格顯示
android:theme="Theme.Light.Panel" 平板風格顯示

 

Android中實現全屏、無標題欄的兩種辦法(另附Android系統自帶樣式的解釋)
http://blog.csdn.net/shakespeare001/article/details/7779011


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM