7

I am currently working on an android project and making use of the SlidingDrawer but I am having a problem with changing the background colour.

By default the SlidingDrawer appears to be transparent so when it is slid up over the content it is hard to read the content of the slidingdrawer due to the main screen being shown underneath.

I wanted to change the background colour to black but for some reason this changes the background colour of the main content so you can't see any of the content and only the content of the sliding drawer when it is pushed up the screen.

Below is the code that I have used to generate the sliding drawer

<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>

Thanks for any help you can provide.

Boardy
  • 35,417
  • 104
  • 256
  • 447

1 Answers1

6

Provide background to the LinearLayout having id of content like this:

<LinearLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:id="@+id/content"
            android:background="#000">
Adil Soomro
  • 37,609
  • 9
  • 103
  • 153
  • Cheers worked great, don't know why I didn't think of that. Thanks again – Boardy Dec 30 '11 at 20:05
  • 1
    This works for me too, but in ICS and Honeycomb I have strange issues. Part of the content when opening drawer becomes transparent or black background again. Very frustrating! – Peterdk Feb 27 '12 at 14:40