2010-07-01 74 views
10

我有一個自定義標題欄安卓:自定義標題欄

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
setContentView(R.layout.activities); 
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); 

其中一期工程基本正常。問題是,直到上面的代碼被稱爲默認標題欄顯示。我根本不想要一個標題欄,換句話說,在我的電影出現之前,沒有標題出現。

添加到這個清單:

<application android:theme="@android:style/Theme.NoTitleBar"> 

導致強制關閉。我的清單看起來像這樣

<application android:icon="@drawable/icon" android:label="@string/app_name" 
    android:theme="@style/My_Theme"> 

,我需要my_Theme因爲它設置背景顏色,設置背景顏色在我的客戶主題導致我的周圍彩色底色的灰色地帶。所以,即使沒有力量關閉,我不知道如果沒有標題會幫助。

有什麼想法?

謝謝。

回答

14

我和你有同樣的問題。

問題出在你的風格上。

嘗試了這一點:因爲

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="My_Theme"> 
     <item name="android:windowTitleSize">35dp</item> 
     <item name="android:windowTitleBackgroundStyle">@android:color/black</item> 
    </style> 
</resources> 
+0

謝謝黑色的黑色隱藏默認設置。 – paradroid666 2010-07-02 10:55:17

+1

你也可以使用'@android:color/transparent'。 – eidylon 2011-05-05 01:42:59

+0

' 1dp'解決了我的問題。 – GAMA 2013-03-29 10:47:57

-1

您的應用崩潰在你的代碼從窗口功能,而在其他方面,你通過清單禁用它調用標題欄。基本上你不能這樣做,它的邏輯不正確。 您需要修改標題欄才能刪除它。

2

這一個也是唯一一個對我來說,這阻止默認標題我的自定義標題開始之前:

<?xml version="1.0" encoding="utf-8"?> 
<resources xmlns:android="http://schemas.android.com/apk/res/android"> 

    <style name="CustomWindowTitleStyle"> 
     <item name="android:textColor">@android:color/transparent</item> 
    </style> 

    <style name="CustomTheme" parent="@android:style/Theme.Holo"> 
     <item name="android:windowActionBar">false</item> 
     <item name="android:windowTitleBackgroundStyle">@android:color/transparent</item> 
     <item name="android:windowTitleSize">50dp</item> 
     <item name="android:windowTitleStyle">@style/CustomWindowTitleStyle</item> 
    </style> 

</resources> 
0

您也應該檢查是否customTitle被它支持或不。

Boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
     setContentView(R.layout.main); 



if (customTitleSupported) { 
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title); 

}