Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable swipe of only the right navigation drawer?

I have two navigation drawers on either side in my Activity. I don't need the right navigation drawer to be opened by a swipe gesture.

If I use:

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)

to lock the swipe then both the left and right drawers are locked. But I want the left drawer to detect the swipe gesture. How do I do this?

<android.support.v4.widget.DrawerLayout 
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="@dimen/nav_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="left" />

    <ListView
        android:id="@+id/right_drawer"
        android:layout_width="@dimen/nav_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="right" />

</android.support.v4.widget.DrawerLayout>
like image 808
DevAndroid Avatar asked Feb 06 '14 05:02

DevAndroid


People also ask

How do I turn off swipe navigation on Android?

Open your phone's Settings app. Swipe up on Home button. Turn Swipe up on Home button off or on. If you turn it on, you're using 2-button navigation.


1 Answers

Achieved it using the same function setDrawerLockMode with an additional parameter

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, findViewById(R.id.right_drawer));
like image 192
DevAndroid Avatar answered Oct 12 '22 00:10

DevAndroid