NavigationView and ActionBarDrawerToggle

前端 未结 3 1843
渐次进展
渐次进展 2021-01-02 08:44

With the new NavigationView is it still recommended to use ActionBarDrawerToggle or is this not \"Material Design\"? For instance previously we we

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-02 09:16

    With the new NavigationView is it still recommended to use ActionBarDrawerToggle

    Yes. The two tackle two completely different aspects of the navigation drawer.

    In total, there are generally three components to a navigation drawer:

    • A DrawerLayout
    • Your navigation drawer content
    • A method of showing and hiding the drawer

    The DrawerLayout is the layout that holds the navigation drawer content and your app's content. It is what allows you to pull the drawer in from the side and display the drawer over your app's content (the first child of the DrawerLayout).

    Your navigation drawer content (the second child of your DrawerLayout) is typically a list of items that the user can click on. Previously, most implementations that I have seen used a ListView or a RecyclerView and maybe a header of some sort. NavigationView is a replacement for this, and is used to provide Material-compliant drawer contents.

    ActionBarDrawerToggle is used to provide the hamburger icon in your app bar. It is what allows your users to tap on the icon to open or close your drawer.

提交回复
热议问题