If I set the order as seen in the picture –> Image
The DrawerLayout is drawn under the content_main And the DrawerLayout dosen’t get OnClickEvents
If I set The Order: first content_main then drawer_layout
The DrawerLayout is drawn over the content_main but the content_main doesn’t get OnClick Events
Here my activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/toolbar" android:clickable="true"> <!--The main content view--> <!--The navigation drawer--> <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="#fff" android:visibility="visible"/> </android.support.v4.widget.DrawerLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/toolbar" android:id="@+id/content_main" android:focusable="false"> </RelativeLayout> </RelativeLayout>
The Problem is only one of the layouts get OnClickEvents. How do i do that both Layouts get OnClickEvents.
Sorry for my English.
Advertisement
Answer
You should put the content_main into the DrawerLayout as seen in the picture.