2011-04-12 80 views
0

編程設置窗口標題欄圖標導致每個列表視圖項目都具有平鋪欄圖標作爲背景。Android窗口標題欄圖標導致列表視圖項目的背景

setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ball);

如何刪除ListView的背景圖像或設置窗口的標題欄圖標不是方案的其他方式?

隨着窗口標題圖標設置

enter image description here

用了窗口標題圖標

enter image description here

--update

<?xml version="1.0" encoding="utf-8"?> 
<!-- Sets the text styles --> 
<resources> 
    <style name="CustomWindowTitleText" parent="android:TextAppearance.WindowTitle"> 
      <item name="android:textSize">24dip</item> 
      <item name="android:textColor">#ffffff</item> 
      <item name="android:textStyle">bold</item> 
      <item name="android:typeface">normal</item> 
    </style> 
    <!-- Changes the background color of the title bar --> 
    <style name="CustomWindowTitleBackground"> 
      <item name="android:background">@drawable/bg_gradient_05</item> 
      <item name="android:paddingLeft">10dp</item> 
    </style> 
    <!-- Set the theme for the window title --> 
    <!-- NOTE: setting android:textAppearence to style defined above --> 
    <style name="CustomWindowTitle" parent="android:WindowTitle"> 
      <item name="android:textAppearance">@style/CustomWindowTitleText</item> 
      <item name="android:shadowDx">0</item> 
      <item name="android:shadowDy">0</item> 
      <item name="android:shadowRadius">0</item> 
      <item name="android:shadowColor">#a0a0a0</item> 
     </style> 
     <!-- Override properties in the default theme --> 
     <!-- NOTE: you must explicitly the windowTitleSize property, the title bar will not re-size automatically, text will be clipped --> 
     <style name="CustomTheme" parent="android:Theme"> 
      <item name="android:windowTitleSize">50dip</item> 
      <item name="android:windowTitleStyle">@style/CustomWindowTitle</item> 
      <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item> 
     </style> 
</resources> 
+0

爲什麼不使用自定義標題欄? – 2011-04-12 05:49:46

+0

@Tanmay Mandal已經在使用自定義標題欄 – 2011-04-12 07:06:02

+0

woww ..... Sweepshots luk hav改變了..... !!! – 2011-04-16 06:43:53

回答

2

使用下面的代碼

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

請確保您在使用R.layout.custom_title以前requestWindowFeature。這裏setContentView使用自定義XML稱號。

我想這會幫助你。

+0

@Tanmay Mandal我已經這樣做了,但是每當方向改變時問題仍然會發生 – 2011-04-16 05:35:07

+0

使用景觀/門廊的兩個不同的佈局 – 2011-04-16 17:58:05

+0

@Tanmay Mandal現在你在這裏使用3個佈局,一個用於主要活動,另外兩個用於標籤 – 2011-04-18 09:25:24