Android Slide Menu-drawerlayout Basic use

Source: Internet
Author: User

In the current mainstream app development, part of the main layout of the side-slip menu, once made Android slide menu. Most choose to use the third-party open-source framework on GitHub Sildingmenu, but the framework is slightly cumbersome. The good news is that Google has open source a side-slip menu layout component: Drawerlayout. Drawerlayout is a component in the V4 package. is also directly inherited from the ViewGroup class. So this class is also a container class. Using the drawerlayout can easily achieve the drawer effect, the steps to use the Drawerlayout have the following 1 points:

1) in Drawerlayout, the first child view must be a view of the display content, and setting its Layout_width and Layout_height properties is match_parent.

2) The second view is a drawer view, and the property layout_gravity= "Left|right", which indicates whether to slide out from the left or the right. Set it's layout_height= "Match_parent"

<android.support.v4.widget.drawerlayout xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns : tools= "Http://schemas.android.com/tools"    android:id= "@+id/drawerlayout"    android:layout_width= "Match_ Parent "    android:layout_height=" match_parent "    tools:context=". Mainactivity ">     <textview        android:id=" @+id/textview "        android:layout_width=" Match_parent        " android:layout_height= "Match_parent"        android:gravity= "center"        android:text= "content"/>     < ListView        android:id= "@+id/listview"        android:layout_width= "80DP"        android:layout_height= "Match_ Parent "        android:layout_gravity=" left "        android:background=" #FFB5C5 "/> </ Android.support.v4.widget.drawerlayout>


Android Slide Menu-drawerlayout Basic use

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.