How to show/Hide Navigation Drawer programmatically

前端 未结 4 851
既然无缘
既然无缘 2021-02-02 05:56

How can I use button to show/hide Navigation Drawer, I have used this SO link to create and manage Navigation Drawer.

Now i am using (Swipe to right from left - to show)

4条回答
  •  攒了一身酷
    2021-02-02 06:45

    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);
    

提交回复
热议问题