Android: Prevent DrawerLayout from passing touch events to views behind

Posted: December 23, 2015 in Android

I have an Android project using DrawerLayout, it’s working fine except that when touching on the empty area of the drawer, the touch events are caught by views behind.

To resolve it, you can add android:clickable=”true” to the drawer view.

< xmlns: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" <strong>android:clickable="true"</strong> android:importantForAccessibility="no" android:layout_height="match_parent" android:layout_gravity="left"/>

But if your drawer view is included using fragment instead of framelayout, you need add the android:clickable=”true” to the root tag of the fragment layout xml.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s