How to open Navigation Drawer with no actionbar, open with just a button

前端 未结 7 1626
悲&欢浪女
悲&欢浪女 2020-12-02 09:37

I have a navigation bar without any actionbar (I don\'t want an actionbar). I\'m trying to make it so that I have a button that can open the navigation drawer.

I kn

7条回答
  •  無奈伤痛
    2020-12-02 09:44

    Kotlin Solution
    If you want to open it from a fragment, you can use:

    activity?.drawerLayout?.openDrawer(GravityCompat.START)
    

    or inside the activity directly:

    drawerLayout.openDrawer(GravityCompat.START)
    

    Note:
    If you are not familiar with the '?', I highly recommend reading about null saftey from kotlin's documentation (It is very short don't worry): https://kotlinlang.org/docs/reference/null-safety.html

提交回复
热议问题