What's the purpose of tools:openDrawer=“start” when creating a DrawerLayout (with NavigationView) from the wizard?

前端 未结 2 585
既然无缘
既然无缘 2021-01-07 22:40

Creating an activity with navigation drawer in Android Studio causes this to be shown in the XML code:



        
相关标签:
2条回答
  • 2021-01-07 23:05

    Android has a dedicated XML namespace intended for tools to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. The namespace URI is http://schemas.android.com/tools and is usually bound to the tools: prefix:

    This means that tools attribute is used by the IDE and not used in the code functionality.

    I am still trying to find the complete documentation of all tools attributes. I can't find out the openDrawer attribute anywhere. But the following are great documentation on tools:

    http://tools.android.com/tech-docs/tools-attributes
    http://tools.android.com/tips/layout-designtime-attributes


    UPDATE

    Now a complete documentation of all tools attribute is available here.

    0 讨论(0)
  • 2021-01-07 23:11

    It makes the navigation drawer visible on the preview screen in Android Studio essentially mimicking the user swiping the drawer onto the screen.

    Without this attribute, you would see only the content view of the main screen.

    I haven't tried it but I suspect substituting "start" for "end" would make the drawer on the right of the screen open (assuming there is one of course).

    0 讨论(0)
提交回复
热议问题