2011-12-30 100 views
7

我目前正在使用SlidingDrawer進行一個Android項目,但我遇到了更改背景顏色的問題。滑動抽屜的背景顏色

默認情況下,SlidingDrawer看起來是透明的,所以當它滑到內容上時,由於主屏幕顯示在下面,所以很難讀取滑動抽屜的內容。

我想將背景顏色更改爲黑色,但由於某些原因,這會更改主要內容的背景顏色,因此無法看到任何內容以及滑動抽屜的內容。屏幕。

下面是我用來產生滑動抽屜

<SlidingDrawer 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:id="@+id/drawer" 
     android:handle="@+id/handle" 
     android:content="@+id/content" 
     android:background="@color/black"> 
     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/handle" 
      android:src="@drawable/ic_launcher"/> 
     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:id="@+id/content"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="I am a sliding drawer - Hello World"/> 
     </LinearLayout> 
    </SlidingDrawer> 

感謝您的幫助,您可以提供的代碼。

回答

6

提供背景內容的ID爲LinearLayout這樣的:

<LinearLayout android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:id="@+id/content" 
      android:background="#000"> 
+0

乾杯偉大的工作,不知道爲什麼我沒有想到這一點。再次感謝 – Boardy 2011-12-30 20:05:40

+1

這也適用於我,但在ICS和蜂窩我有奇怪的問題。打開抽屜時,部分內容變爲透明或黑色背景。非常令人沮喪! – Peterdk 2012-02-27 14:40:16