Android 實現全屏 去掉標題欄

2021-06-17 20:54:10 字數 1677 閱讀 1475

在進行android ui設計時,我們經常需要將螢幕設定成無標題欄或者全屏。要實現起來也非常簡單,主要有兩種方法:配置xml檔案和編寫**設定。

1.在xml檔案中進行配置

在專案的清單檔案androidmanifest.xml中,找到需要全屏或設定成無標題欄的activity,在該activity進行如下配置即可。

實現全屏效果:

android:theme="@android:style/theme.notitlebar.fullscreen"

實現無標題欄(但有系統自帶的工作列):

android:theme="@android:style/theme.notitlebar"

2.編寫**設定

在程式中編寫**進行設定,只需在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.wall*****" 用系統桌面為應用程式背景

android:theme="theme.wall*****.notitlebar" 用系統桌面為應用程式背景,且無標題欄

android:theme="theme.wall*****.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

1 第一種方法最為常見 效果不是很好!requestwindowfeature window.feature no title 去掉標題欄 2 在清單中設定 效果不錯 不會出現標題欄閃一下的情況 drawable icon android label android theme android st...

Android 去掉視窗標題和程式全屏

第一 在程式 中實現 this.requestwindowfeature window.feature no title 去掉標題欄 this.getwindow setflags windowmanager.layoutparams.flag fullscreen,windowmanager.la...

如何在Android中實現全屏,去掉標題欄效果

在進行android ui設計時,我們經常需要將螢幕設定成無標題欄或者全屏。要實現起來也非常簡單,主要有兩種方法 配置xml檔案和編寫 設定。1.在xml檔案中進行配置 在專案的清單檔案androidmanifest.xml中,找到需要全屏或設定成無標題欄的activity,在該activity進行...