How to show/Hide Navigation Drawer programmatically

前端 未结 4 847
既然无缘
既然无缘 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:42

    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.

提交回复
热议问题