2012-07-26 72 views
0

我正在使用滑动抽屉,并且能够在我的应用程序的所有活动中显示滑动抽屉。滑动抽屉打开时不活动的背景

我面临的问题是,我仍然能够点击背景(活动中的视图)。有没有办法可以在滑动抽屉打开时禁用背景。

问候

EDIT 1

<?xml version="1.0" encoding="utf-8"?> 
<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/slidingDrawer1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="20dp" 
    android:layout_marginRight="20dp" 
    android:content="@+id/content" 
    android:handle="@+id/handle" > 

    <Button 
     android:id="@+id/handle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Handle" /> 

    <LinearLayout 
     android:id="@+id/content" 
     style="@style/roundrectbox_white_layout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/slider_round_rect_border" 
     android:orientation="vertical" 
     android:padding="15dp" > 

     <ListView 
      android:id="@+id/listView1" 
      android:layout_width="fill_parent" 
      android:layout_height="match_parent" 
      android:cacheColorHint="@android:color/transparent" 
      android:divider="@android:color/transparent" 
      android:listSelector="@android:color/transparent" /> 
    </LinearLayout> 

</SlidingDrawer> 
+0

您作为滑动抽屉的内容添加了什么? – AkashG 2012-07-26 09:51:52

+0

它是一个listview。 – Deva 2012-07-26 09:53:51

+0

当你拖动滑动抽屉时,你能看到列表视图吗? – AkashG 2012-07-26 09:54:39

回答

0

尝试这种情况:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TextView 
     android:id="@+id/text" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello"/> 

    <SlidingDrawer 
     android:id="@+id/drawer" 
     android:layout_width="320dp" 
     android:layout_height="440dp" 
     android:content="@+id/content" 
     android:handle="@+id/handle" 
     android:orientation="vertical" > 

     <Button 
      android:id="@+id/handle" 
      android:layout_width="fill_parent" 
      android:layout_height="20dp" 
      android:background="@drawable/wood" /> 

     <RelativeLayout 
      android:id="@+id/content" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      > 

       <ListView 
        android:id="@+id/list" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"></ListView> 
     </RelativeLayout> 
    </SlidingDrawer> 

</RelativeLayout> 

而在活动:

ListView listView=(ListView) findViewById(R.id.list); 
     ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,array); 
     listView.setAdapter(adapter); 

其中阵列是:

String[] array={"1","2","3","4"};