Android in Navigation Drawer when I click anywhere drawer closes

I had the same problem once.

I had a RecyclerView NavigationDrawer and by just moving the Navigation code to the bottom of the xml file my problem got solved.

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/DrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="7dp">


<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

//some code here for the body of your activity

</RelativeLayout>


<android.support.v7.widget.RecyclerView
    android:id="@+id/RecyclerView"
    android:layout_width="350dp"
    android:layout_height="match_parent"
    android:layout_gravity="right"
    android:background="#ffffff"
    android:scrollbars="vertical">

</android.support.v7.widget.RecyclerView>

hope it works for you too…

Leave a Comment