android 應用中去掉標題欄的幾種方法

2021-07-24 20:52:03 字數 1801 閱讀 1279

在android應用中經常遇到需要去掉標題欄的需求,總結出三種方法

1,直接在activity中的oncreate方法中加這句話

[html]view plain

copy

print?

<

span

style="color:#009900;"

>this.requestwindowfeature(window.feature_no_title);//去掉標題欄

span

>

this.requestwindowfeature(window.feature_no_title);//去掉標題欄
記住:這句**要寫在setcontentview()前面。

2.在清單檔案(manifest.xml)裡面實現

[html]view plain

copy

print?

<

span

style="color:#009900;"

>

<

android:icon="@drawable/icon"

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

>

span

>

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

3.在style.xml檔案裡定義

[html]view plain

copy

print?

<

span

style="color:#333333;"

>

<

span

>

<

span

style="color:#009900;"

>?xml version="1.0"

encoding="utf-8"

?>

<

resources

>

<

style

name="notitle"

>

<

item

name="android:windownotitle"

>true

item

>

style

>

resources

>

span

>

<

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

然後面manifest.xml中引用就可以了,這種方法稍麻煩了些。

[html]view plain

copy

print?

<

span

style="color:#009900;"

>

<

android:icon="@drawable/icon"

android:theme="@style/notitle"

>

span

>

android:theme="@style/notitle">

第二種方法和第三種方法實質是一樣的,只不過第二種方法呼叫的是系統定義好的style.xml檔案,而第三種方法則是在自己的應用裡定義style.xml,然後再自己再呼叫,其實道理是一樣的。

android應用中去掉標題欄的方法

現在我堅定的認為寫技術部落格對自己有很大的幫助,寫部落格給自己乙個學而思的機會。在android中去掉標題欄有三種方法,它們也有各自的特點。1.在 裡實現 this.requestwindowfeature window.feature no title 去掉標題欄記住 這句 要寫在setconte...

android應用中去掉標題欄的方法

現在我堅定的認為寫技術部落格對自己有很大的幫助,寫部落格給自己乙個學而思的機會。在android中去掉標題欄有三種方法,它們也有各自的特點。1.在 裡實現 this.requestwindowfeature window.feature no title 去掉標題欄記住 這句 要寫在setconte...

android 如何去掉標題欄

在android中去掉標題欄有三種方法,它們也有各自的特點。1.在 裡實現 this requestwindowfeature window.feature no title 去掉標題欄 這句 要寫在setcontentview 前面。2.在清單檔案 manifest.xml 裡面實現 3.在sty...