我想隱藏一些活動的標題欄。 問題是我將一個樣式應用於個人全部活動,所以我不能簡單地將主題設置爲@android:style/Theme.NoTitleBar
。 android
使用NoTitleBar主題做爲個人樣式的父級將從個人全部活動中刪除標題欄。 ide
我能夠在某處設置無標題樣式項嗎? this
若是您執行YaW和Doug Paul所說的用戶,那麼您必須記住在調用setContentView以前必須設置窗口功能。 若是沒有,你會獲得一個例外。 spa
我發現可能發生此錯誤的兩個緣由。 .net
一。 Window標誌已經設置在super.onCreate(savedInstanceState);
在這種狀況下,您可能但願使用如下命令順序: code
this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState);
二。 TitleBar中有Back / Up按鈕,這意味着當前活動是另外一個活動的層次結構子項,在這種狀況下,您可能想要在onCreate
方法中註釋掉或刪除這行代碼。 get
getActionBar().setDisplayHomeAsUpEnabled(true);
在onCreate
方法中,使用如下代碼段: it
this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main);
建立以下主題。 io
<!-- Variation on the Light theme that turns off the title --> <style name="MyTheme" parent="android:style/Theme.Black"> <item name="android:windowNoTitle">true</item> </style>
只需使用getActionBar().hide();
在你的主要活動onCreate()
方法中。 class