My DrawerLayout was inside a LinearLayout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/abohawawallpapersqr"
tools:context=".MainActivity">
<include layout="@layout/toolbar" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- ...... -->
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
Then I solved the problem by changing the layout_height="wrap_content" to layout_height="match_parent" of LinearLayout.So the code is:
<LinearLayout 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"
android:orientation="vertical"
android:background="@drawable/abohawawallpapersqr"
tools:context=".MainActivity">