The weather is too hot to go to work with no mental head. Simply clean up the framework used in the project to extract, convenient next time to use it.
We should all know slidingmenu. GitHub is an open-source framework can be left and right sliding, the current many apps are used, such as NetEase News, 360 mobile phone assistant, embarrassing encyclopedia, Ireader. It should be a very good frame of fire.
No exception our company's projects are also used. There's a lot of crap. Let's go straight to the subject.
First, we introduce the structure of the framework
First a few pictures, do not do gif.
And look at the package structure.
The main implementation of the slide-off function code in the Slidingmenu package. Sliding package is mainly put in the left and right two fragment is the top of the first and last interface.
The UI is placed in the main interface can be Viewpager added in the three fragment and the left menu in the live Hall leaderboard concerns, three fragment.
Then how to use it. The first thing to Mainacitivity is to introduce slidingmenu in the layout to refer to the custom control. The full path name.
Then add a level one or two interface to the Slidingmenu in Mainacitivity. and SetContent.
The code is as follows:
Mslidingmenu = (slidingmenu) Findviewbyid (R.id.slidingmenu); Mslidingmenu.setmenu (R.layout.sliding_left_frame) ; Set the left side if (Getfragmentbytag (leftfragment.class) = = null) {Getsupportfragmentmanager (). BeginTransaction (). Add ( R.id.left_frame, New Leftfragment (), LeftFragment.class.getName ()). commit ();} Mslidingmenu.setcontent (R.layout.sliding_center_frame); Set Intermediate mslidingmenu.setsecondarymenu (R.layout.sliding_right_frame); Set the right if (Getfragmentbytag (rightfragment.class) = = null) {Getsupportfragmentmanager (). BeginTransaction (). Add ( R.id.right_frame, New Rightfragment (), RightFragment.class.getName ()). commit ();} if (mcurfragment! = null) {postswitchfragment ();} Mslidingmenu.settouchmodeabove (Slidingmenu.touchmode_margin); Sets the touch mode. This is the edge slide, can also be changed to fullscreen.
The remaining code is relatively simple. There is a need to look under the download to see below.
Attached Demo: click here.
Technology without him, only hand-cooked. This sentence is right, no need to envy others, refueling!