Home » Android » android – DrawerLayout lock mode doesnt work as expected

android – DrawerLayout lock mode doesnt work as expected

Posted by: admin June 16, 2020 Leave a comment


My code below locks the drawerlayout when using a tablet (in landscape mode)

    //Landscape mode
    //Portrait mode

However, if I open it up in landscape it locks the drawerlayout as expected, however when changing it to portrait mode I cannot swipe it away. It does the opposite when opening it up in portrait (allows me to open and close) but then changing to landscape it opens it but doesn’t lock it in so the user can swipe it away and break the view.

Not to sure what I am missing, as I have stepped through the code countless times and it follows the right paths.

How to&Answers:

I had the same issue and moving that code to my onResume() did the trick.