0

android 中的 SlideDrawer 始终显示为透明,我如何设置背景并避免透明。这是 SlidingDrawer 控件的代码,我尝试设置此 android:background="@drawable/menubg" 但仍显示为透明。

  <?xml version="1.0" encoding="utf-8"?>
    <SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/SlidingDrawer"
        android:layout_width="wrap_content"
        android:layout_height="250dp"
        android:content="@+id/contentLayout"
        android:handle="@+id/slideButton"
        android:orientation="vertical"
        android:padding="10dip"
        >

        <Button
            android:id="@+id/slideButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/menubtnup" >
        </Button>

        <RelativeLayout
            android:id="@+id/contentLayout"
            android:layout_width="wrap_content"
            android:layout_height="200dp"
            android:background="@drawable/menubg" >

            <ScrollView
                android:id="@+id/scrollView1"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:layout_marginTop="15dp" >

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="vertical" >

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:weightSum="3" >

                        <Button
                            android:id="@+id/Button01"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:background="@drawable/ind_slc" />

                        <Button
                            android:id="@+id/Button02"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:background="@drawable/rec_slc" />

                        <Button
                            android:id="@+id/button1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:background="@drawable/about_slc" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:weightSum="3" >

                        <Button
                            android:id="@+id/Button01"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:background="@drawable/fav_slc" />

                        <Button
                            android:id="@+id/Button02"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:background="@drawable/request_slc" />

                        <Button
                            android:id="@+id/button1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:background="@drawable/subscripe_slc" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:weightSum="3" >

                        <Button
                            android:id="@+id/Button01"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:background="@drawable/tell_slc" />

                        <Button
                            android:id="@+id/Button02"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:background="@drawable/sponser_slc" />

                        <Button
                            android:id="@+id/button1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:background="@drawable/settings_slc" />
                    </LinearLayout>
                </LinearLayout>
            </ScrollView>
        </RelativeLayout>

    </SlidingDrawer>

谁能帮我?

4

1 回答 1

0

您可以使用其他布局并将每个控件放在其中...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="somevalue" >
<SlidingDrawer 
    android:id="@+id/SlidingDrawer"
    android:layout_width="wrap_content"
    android:layout_height="250dp"
    android:content="@+id/contentLayout"
    android:handle="@+id/slideButton"
    android:orientation="vertical"
    android:padding="10dip"
    >

    <Button
        android:id="@+id/slideButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/menubtnup" >
    </Button>
    ...
    ...
    ...    //more of your code
   </SlidingDrawer>
  </LinearLayout>

仅将父线性布局的背景更改为您喜欢的值...试试看...告诉它是否有效

于 2013-04-02T20:32:46.027 回答