0

我想用背景色在xml中制作抽屉,当我打开抽屉时,我看到了背景色,但如果我没有打开抽屉,我看不到背景色。

这就是我的 xml 的样子——

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

1 回答 1

0

您需要在“内容”布局中设置背景颜色。

试试这个。

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

希望它的帮助

于 2014-07-28T00:09:04.960 回答