How to open navigation drawer on button click in main fragment?

后端 未结 5 1907
我在风中等你
我在风中等你 2020-12-08 03:02

I have made an app with one activity which uses a navigation drawer to open a number of different fragments. I have the actionbar drawertoggle, but it is not very visible. I

5条回答
  •  既然无缘
    2020-12-08 03:26

    Use these lines to open and close the drawer on a certain event:

    Code snippet for opening drawer:

    drawerLayout.openDrawer(Gravity.START);
    

    Code snippet for closing drawer:

    drawerLayout.closeDrawer(Gravity.LEFT);
    

    openDrawer(gravity_of_navigation_view_to_be_shown)

    in openDrawer("gravity"), in "gravity" section, you have to input the gravity of the Navigation View like given above:

    Gravity.LEFT
    Gravity.RIGHT
    Gravity.START
    Gravity.END
    

    I think thats the best answer.

提交回复
热议问题