Usage of navigationdrawer (navigation drawer)

Source: Internet
Author: User

On the day of the 2013 Google Io, the Android team updated the support library and added the Navigationdrawer (navigation menu).

1. Create Drawerlayout

Create Drawerlayout

In the interface that needs the drawer menu, use DrawerLayout as the interface root control. In Drawerlayout, the first view is the main content of the current interface, and the second and third view are the contents of the Drawer menu. If the current interface requires only one drawer menu, the third view can be omitted.

In the following example, Drawerlayout contains two view, the first framelayout is the main content display area of the current interface, and the second ListView is the contents of a drawer menu.

<Android.support.v4.widget.DrawerLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:id= "@+id/drawer_layout"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent">    <!--The main content view. -    <FramelayoutAndroid:id= "@+id/content_frame"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent" />    <!--The navigation drawer. -    <ListViewAndroid:id= "@+id/left_drawer"Android:layout_width= "240DP"Android:layout_height= "Match_parent"android:layout_gravity= "Start"Android:choicemode= "Singlechoice"Android:divider= "@android: Color/transparent"Android:dividerheight= "0DP"Android:background= "#111"/></Android.support.v4.widget.DrawerLayout>

    • The view (above) that displays the main interface content of the interface FrameLayout must be the first child view of Drawerlayout, because the view order in the XML layout file is the z-ordering order in the Android system. The drawer must appear on top of the content.
    • The view width and height of the display interface content is set to the same as the parent view, because the interface content represents the entire interface UI when the drawer menu is not visible.
    • The drawer menu (above ListView ) must use the Android:layout_gravity property to set the horizontal gravity value . If you want to support Right-to-left (RTL, right-to-left reading) language "start" instead of (when the RTL language is running, the menu appears on the right).
    • The width of the drawer menu is the same as the height of the dp parent view. The width of the drawer menu should be no more than 320DP, so that users can see some content interface when the menu is open.

.

Usage of navigationdrawer (navigation drawer)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.