Android中全屏或者取消標題欄

2021-06-16 14:51:17 字數 1510 閱讀 6258

requestwindowfeature(window.feature_no_title);

//去掉標題欄

注意這句一定要寫在setcontentview()方法的前面,不然會報錯的

<="

@drawable/icon

"android:label="

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

可以看出,這樣寫的話,整個應用都會去掉標題欄,如果只想去掉某乙個activity的標題欄的話,可以把這個屬性加到activity標籤裡面

例如:

<?

xml version="1.0" encoding="utf-8"

?>

<

resources

>

<

style

name

="notitle"

>

<

item

name

="android:windownotitle"

>

true

item

>

style

>

resources

>

這樣,我們就自定義了乙個style,就相當於乙個主題,然後在androidmanifest.xml檔案中定義

<

android:icon

="@drawable/icon"

android:label

android:theme="@style/notitle">

這樣也可以達到去掉標題欄的效果

第一種,有的時候我們會看到,會先出現標題欄,然後再消失,因為我們只是在activity的oncreate方法中定義的,第二種相對第一種比較好一些,不會出現這種情況,第三種我個人感覺最好,這樣把功能分開,便於維護和擴充套件

第一種

getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen);

第二種

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

第三種

android:icon

="@drawable/icon"

android:label

android:theme

="@style/fullscreem"

Android中全屏或者取消標題欄

requestwindowfeature window.feature no title 去掉標題欄 注意這句一定要寫在setcontentview 方法的前面,不然會報錯的 drawable icon android label android theme android style theme....

Android全屏或者取消標題欄

requestwindowfeature window.feature no title 去掉標題欄 注意這句一定要寫在setcontentview 方法的前面,不然會報錯的 drawable icon android label android theme android style theme....

Android 切換全屏,取消全屏

切換全屏,取消全屏 param ischecked private void switchfullscreen boolean ischecked else 橫豎屏切換時的生命週期總結 1 不設定activity的android configchanges時,切屏會重新呼叫各個生命週期,切橫屏時會執...