setDrawerLockMode not working in android?
Asked Answered
H

1

8

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.

Houseline answered 7/1, 2016 at 10:36 Comment(2)
visit #27074606Starling
I see this not fix my case, the same issue: #18413616 . But no one can fix it.Cosper
C
1

Add gravity value too when using setDrawerLockMode();

Do this :

drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END);

This should work

Comforter answered 10/8, 2017 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.