Official website: https://developer.android.com/training/implementing-navigation/nav-drawer.html
Paste the main logic and layout files:
activity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
Something to note here: the main content interface must be defined in front of the drawer. In addition, Android:layout_gravity="start" (from left to right) or android:layout_gravity="end" (from right to Left), this attribute must be defined, otherwise the following exception will occur:
MainActivity.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
The rendering is as follows:
The above is the example code of Android DrawerLayout that the editor introduces to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will promptly Reply to everyone. I would also like to thank you all for your support of the PHP Chinese website!
For more Android DrawerLayout implementation of drawer effect example code related articles, please pay attention to the PHP Chinese website!