http://www.jianshu.com/p/c8cbeb7ea43a
Use Navigation Drawer and Navigation View to achieve left and right side slide
You don't even have to write anything in the activity.
Navigationdrawer Introduction
Navigationdrawer is a side-by-side navigation bar design style introduced by Google in Material. may be very abstract, we directly to see NetEase cloud Music slide navigation bar effect
Google has introduced a new control--drawerlayout to support this navigation effect. But before Drawerlayout was born, the need to realize the sliding navigation effect, we will choose to choose some mature third-party open source libraries (such as the most famous Slidingmenu) to complete the development.
After comparing the implementation of Drawerlayout and Slidingmenu , based on the following points, I think it is entirely possible to use drawerlayout in development to replace the previous Slidingmenu:
- From the animation effect, you will find that the two are only a few differences in the effect of the movement, other places are not too big differences
- In the interactive effect, I think the two are similar, even if you put NetEase cloud music effect on the hand Q , will not affect the user's interaction
- Drawerlayout is easier to use than Slidingmenu , with less code (see below)
- drawerlayout is backwards compatible, so there is no low-version compatibility issue
- Google Pro son, no reason not to support AH!!!!!!
Here, if you have not yet introduced the impulse of drawerlayout Development, please continue to listen to me for your good.
Under normal circumstances, the
DrawerlayoutThere are only two sub-layouts under the layout, one
Content Layoutand a
Slide Menu Layout, the key to these two layouts is
android:layout_gravityThe settings for the property. If you want to set one of the sub-layouts to be the left-hand slide menu, you only need to set
android:layout_gravity= "Start"(or left, or end or right), and the layout without settings naturally becomes
Content Layout。
to recognize Navigationview
Navigationview and drawerlayout are the best combination of official recommendations in Google's launch of the navigationdrawer design. Before using Navigationview, because it is in the Compatibility pack of Material Design, you need to first introduce it in Build.gradle
‘com.android.support:design:23.1.1‘
Actionbardrawertoggle
Implement return picture and animation effects
http://blog.csdn.net/chencehnggq/article/details/21492417
http://blog.csdn.net/zxm317122667/article/details/50989346
Actionbardrawertoggle is the listener for the Drawerlayout event.
Actionbardrawertoggle has 3 methods that can be replicated to implement Drawerlayout open, close, and sliding event monitoring:
Ondraweropened Drawerlayout is called when sliding out
ondrawerclosed Drawerlayout closed when called
Ondrawerslide Drawerlayout is called when sliding
Android-navigation Drawer