Search code examples
androidxmlandroid-handlerandroid-slidingandroid-background

how to choose color for slidingdrawer


I want to make drawer in xml with backcolor, and when I open the drawer, I see the backcolor, but if I didnt open the drawer I dont see the backcolor.

This is what my xml looks like-

<SlidingDrawer

    android:id="@+id/slidingD"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:content="@+id/content"
    android:handle="@+id/handle" 

    android:layout_marginTop="150dp">

    <Button
        android:id="@+id/handle"
        android:layout_width="wrap_content"

        android:layout_height="wrap_content"
        android:text="^" />


    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <CheckBox
            android:id="@+id/cbSlidable"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="CheckBox" />
    </LinearLayout>
</SlidingDrawer>

Solution

  • you need to set background color in you "content" layout.

    Try this.

    <SlidingDrawer
    
    android:id="@+id/slidingD"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:content="@+id/content"
    android:handle="@+id/handle" 
    android:layout_marginTop="150dp">
    
    <Button
        android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="^" />
    
    
    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/black">
    
        <CheckBox
            android:id="@+id/cbSlidable"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="CheckBox" />
    </LinearLayout></SlidingDrawer>
    

    Hope its help