兩種方式:
-
在xml文件中進行配置
在項目的清單文件AndroidManifest.xml中,找到需要全屏或設置成無標題欄的Activity,在該Activity進行如下配置即可。
實現全屏效果:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
實現無標題欄(但有系統自帶的任務欄):
android:theme="@android:style/Theme.NoTitleBar" -
編寫代碼設置
在程序中編寫代碼進行設置,只需在onCreate()方法中加入如下代碼即可
實現全屏效果:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
實現無標題欄(但有系統自帶的任務欄):
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" 平板風格顯示
注:轉載自網絡,侵刪