无法单击DrawerLayout后面的按钮

Suh*_*gar 4 android imagebutton android-layout navigation-drawer drawerlayout

这是我的xml:

<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>
Run Code Online (Sandbox Code Playgroud)

我写了它的程序化部分和Drawer工作就好了,只是我不能点击它背后ImageButtons .如果我把按钮放在前面我可以点击它们,但是抽屉被留下了,这是一个可怕的景象.这是什么解决方案?我怎样才能点击抽屉后面的按钮并看到前面的抽屉?

提前致谢.

sta*_*an0 9

根据导航抽屉指南,DrawerLayout 应该是您的布局.它应该只有2个孩子 - 一个包含你的"主要内容" - 按钮,文本字段等.另一个应该是抽屉本身的内容.像这样的东西:

<android.support.v4.widget.DrawerLayout>

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

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

</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

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