How to show/Hide Navigation Drawer programmatically

Solution 1:

Grab a reference to the DrawerLayout and call closeDrawer(int) to close it and openDrawer(int) to open it. The int parameter refers to the gravity. In your case it should be GravityCompat.LEFT/ GravityCompat.START, because accordingly to the screenshot you posted, your DrawerLayout open and close on the left.

Solution 2:

to Close Drawer:

drawer.CloseDrawer((int)GravityFlags.Left);

to Open Drawer:

drawer.OpenDrawer((int)GravityFlags.Left);

Solution 3:

To open the Drawer

DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.openDrawer(GravityCompat.START);

To close the drawer

DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);