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.