三種方法:
- 方法一 : (利用代碼)
//設(shè)置窗體為沒有標(biāo)題的模式
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
- 方法二 : (利用清單文件manifest.xml)
android:theme="@android:style/Theme.NoTitleBar"
將上述代碼添加到需要隱藏標(biāo)題欄的Activity的屬性中
例如 : (關(guān)鍵是最后一行代碼)
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar">
- 方法三 : (類似方法二)(思路是在style.xml文件里定義如下代碼,然后在manifest.xml中引入即可)
具體代碼如下:
style.xml
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<style name="notitle">
<item name="android:windowNoTitle">true</item>
</style>
</resources>
manifest.xml (關(guān)鍵是最后一行代碼)
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/notitle">
其實(shí)第三種方法和第二種方法的原理相似,只不過第三種方法更利于代碼的復(fù)用,如果你要自定義許多安卓的控件屬性,而且需要在許多APP中使用這些你自己定義的控件屬性,就可以使用第三種方法,然后只需要引入你自己編輯好的style.xml文件即可.