DrawerLayout通过include引进的布局菜单穿透

当DrawerLayout里的菜单是通过include引进菜单布局时,点击菜单的空白部分会穿透从而触发主内容布局中的事件。

解决方法:(超简单)

在include的布局里添加clickable="true"即可

例如include如下

<include
  android:id="@+id/main_menu"
  layout="@layout/layout_main_menu"
  android:layout_width="300dp"
  android:layout_height="match_parent"
  android:layout_gravity="start" />

那么在layout_main_menu文件的根布局加上clickable="true"

原文地址:https://www.cnblogs.com/kangweifeng/p/5310261.html