Drawerlayout implementation of the Android component drawer menu _android

Source: Internet
Author: User

The Drawerlayout component is also a component in the V4 package and is directly inherited from the ViewGroup class, so this class is also a container class.

The placement and layout of the drawer menu is controlled by the Android:layout_gravity property, with the optional value left, right, or start, end. By using XML to lay out the words, need to take drawerlayout as the parent container, the group interface layout as its first child node, the drawer layout is followed by the second child node, so that the content display area and the Drawer menu area are separated, only need to set the content of two regions. Android provides a number of useful listeners, and overload-related callback methods can write logical business during menu interaction.

The use of drawerlayout can easily achieve the drawer effect, the use of drawerlayout steps have the following 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 the drawer view and sets the property layout_gravity= "Left|right" to indicate whether it slides from the left or right. Set its layout_height= "Match_parent"

eg

<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>

Effect of implementation:


The above is a small set to introduce the Android components of the drawerlayout implementation of the Drawer menu knowledge, hope to help.

Related Article

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.