I want to lock swipe left-right and right-left of DrawerLayout.
DrawerLayout drawerLayout;
onCreate:
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
Click button to open drawerLayout:
drawerLayout.openDrawer(Gravity.LEFT);
and close:
drawerLayout.closeDrawers();
I try setDrawerLockMode in onCreate, onResume, onStart but not working, it still can open, close by swipe it.
Edit 2:
It work with:
android:layout_gravity="start"
and not work with:
android:layout_gravity="start|bottom"
Any helps. Thanks.
Add gravity value too when using setDrawerLockMode();
Do this :
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END);
This should work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With