android – Touch anywhere to slide open menu for navigation drawer-ThrowExceptions

Exception or error:

For Sliding menu by jfeinstein10 (, I can slide anywhere in the app to slide open the menu.

For Google newly introduced navigation drawer, is there any way I can have similar behaviour?

So far, from documentation, I saw it only limit to slide from edge or touching the app icon.

The user can bring the navigation drawer onto the screen by swiping
from the left edge of the screen or by touching the application icon
on the action bar.

How to solve:

I have found a solution. You can configure margin of touch and make it as wide as your view is. Here is the link

Set drag margin for Android Navigation Drawer


Google, from the way they word their tutorial “If the user touches the very left edge of the screen (within 20 dp from the left)”, seems like they don’t want that functionality.


“The user can bring the navigation drawer onto the screen by swiping from the left edge of the screen or by touching the application icon on the action bar.”

They do not say or swipe from anywhere on the screen. They also do not have that functionality in any of their apps (G+, Gmail, etc.), so if you want that functionality you should probably stick with writing your own (with gestures) or third party (eg. jfeinstein10).

Youtube app does let you swipe anywhere but the version I have at least (4.5.17) doesn’t look like it is using their new api.


You can use this

DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(;
Field mDragger = mDrawerLayout.getClass().getDeclaredField(
    "mLeftDragger");//mRightDragger or mLeftDragger based on Drawer Gravity
ViewDragHelper draggerObj = (ViewDragHelper) mDragger

Field mEdgeSize = draggerObj.getClass().getDeclaredField(
int edge = mEdgeSize.getInt(draggerObj);

mEdgeSize.setInt(draggerObj, edge * 3); 


As others have said, and Cheney has said in his answer – it’s probably best to leave it as intended. However, the DrawerLayout is a different style than the SlidingMenu. Google also added SlidingPaneLayout which matches the style of SlidingMenu more closely.

I ended up implementing a SlidingPaneLayout in this way, as it was more of what I was looking for after all. (This is also the style of the YouTube/Hangouts app)





Then to open with the action bar home button:


public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action buttons
    switch(item.getItemId()) {
            if (mPaneLayout.isOpen())
            return true;
            return super.onOptionsItemSelected(item);

You can then implement a PanelSlideListener to handle when it sliding/open/closed.

I suggest reading Adam Powell’s series on the navigation drawer too – part 3 gets into usage of SlidingPaneLayout vs Navigation Drawer:

Part 1 –

Part 2 –

Part 3 –

Part 4 –


You could use a GestureDetector to detect sliding gestures yourself and simply open the Navigation Drawer yourself using the DrawerLayout.openDrawer() method.

Leave a Reply

Your email address will not be published. Required fields are marked *