4

这里背后的按钮是我的xml:不能单击DrawerLayout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".Main" 
android:background="@android:color/black" > 

    <RelativeLayout 
    android:id="@+id/layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <ImageButton 
     android:id="@+id/calendar" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/about" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/calendar" /> 

    <ImageButton 
     android:id="@+id/okan" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/calendar" 
     android:layout_marginLeft="20dp" 
     android:layout_toRightOf="@+id/calendar" 
     android:background="@drawable/okanliyiz"/> 

    <ImageButton 
     android:id="@+id/about" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="20dp" 
     android:layout_marginTop="140dp" 
     android:layout_toLeftOf="@+id/calendar" 
     android:background="@drawable/info" /> 

</RelativeLayout> 

<android.support.v4.widget.DrawerLayout 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:clickable="false" > 

<FrameLayout 
    android:id="@+id/content_frame" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:clickable="false" /> 

<ListView 
    android:id="@+id/left_drawer" 
    android:layout_width="240dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="0dp" 
    android:background="#111"/> 
</android.support.v4.widget.DrawerLayout> 


</RelativeLayout> 

我写它的纲领性部分和Drawer作品就好了,这只是我不能点击ImageButton小号背后它。如果我把按钮放在前面,我可以很好地点击它们,然后抽屉被留下,这是一个可怕的景象。这是什么解决方法?我怎样才能点击抽屉后面的按钮并看到前面的抽屉?

在此先感谢。

回答

7

根据您的布局的Navigation Drawer guideDrawerLayoutshould be the root。它应该有只有2个孩子 - 一个包含您的“主要内容” - 按钮,文本字段等。另一个应该是抽屉本身的内容。事情是这样的:

<RelativeLayout> 

    <RelativeLayout> 
     <Button/> 
     <EditText/> 
    </RelativeLayout> 

    <ListView android:id="@+id/drawer_list" /> 

</RelativeLayout> 

另外: 的2个孩子的顺序很重要,由于DrawerLayout(这是一个ViewGroup)的Z顺序。列表视图应在主内容之后声明,以便在其前面排序(并显示)。

相关问题