Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NavigationDrawer disable right swipe

I have DrawerLayout setup with a drawer on either side

<FrameLayout android:id="@+id/navigation_drawer"
    android:layout_width="@dimen/navigation_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="start" />


<FrameLayout android:id="@+id/navigation_drawer_right"
    android:layout_width="@dimen/navigation_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="end" />

The right drawer is populated when a certain method is run, however, before that method is run I can swipe from the right and the screen dims but nothing shows (because the layout is empty until the method has been run).

How can I disable swipe from the right until the method has been run? I've seen solutions to fully disable any swiping, but that wouldn't work for me as the left drawer needs to always work (the setup right draw function is called when a particular option is selected on the left drawer).

Or, would there be a better way to do this? Maybe dynamically adding the right FrameLayout when the function is run?

like image 609
TMH Avatar asked Oct 25 '13 14:10

TMH


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.

How do I change left and right swipe on Android?

Tap the settings icon. Tap General. Scroll down to Swipe actions at the bottom of the screen. Choose whether you want to Select, Complete or Schedule a task when swiping left or right.


1 Answers

This disables the swipe:

mDrawerLayout = (DrawerLayout) findViewById(R.id.navigation_drawer_right);
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

And to enable swipe:

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
like image 152
Kevin van Mierlo Avatar answered Oct 11 '22 14:10

Kevin van Mierlo