Android: How do I keep DrawerLayout from passing touch events to the underlying view
Set clickable to true on the drawer - it'll consume the touch.
<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">
<FrameLayout
android:id="@+id/content_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+id/drawer_view"
android:layout_width="300dp"
android:clickable="true"
android:importantForAccessibility="no"
android:layout_height="match_parent"
android:layout_gravity="left"/>
</android.support.v4.widget.DrawerLayout>
I added android:importantForAccessibility="no"
because marking the drawer as interactive (clickable or focusable) will make the entire drawer visible to accessibility services like TalkBack.
This is not what you want (usually) - more often, items inside the drawer should be accessible to the services.
This attribute is only available on API 16+.