If you want to view the source directly, you can download it from my github. View: Https://github.com/zhanghuijun0/demo-for-android/tree/master/SlidingMenu
Slidingmenu is an Android open source project on GitHub that can be used to quickly integrate the Android slide menu effect, Slidingmenu inside can contain a variety of components fragment Viewpager listview, etc.;
:
Slidingmenu:https://github.com/jfeinstein10/slidingmenu
Actionbarsherlock:https://github.com/jakewharton/actionbarsherlock/tree/master/actionbarsherlock
Note: Slidingmenu relies on another open source project Actionbarsherlock, so you need to add Actionbarsherlock as a Slidingmenu library project, otherwise you will report that the resource could not find an error.
The dependencies are as follows: Examplelistactivity-->library-->actionbarsherlock
Frequently-occurring problems:
(1) After the dependency is added, the Jar mismatch! is reported Fix your dependencies "error, which is caused by a mismatch in the Android-support-v4.jar version. (The solution, delete the dependent Android-support-v4.jar, re-add the new, of course, can also be copied from one of the projects to another project, the purpose is to Android-support-v4.jar version to be the same OK)
(2) There is also an error in the Library: Getsupportactionbar () cannot be found. Setdisplayhomeasupenabled (true);
Workaround: Locate the Slidingfragmentactivity.java under SRC in the library and modify the parent class to:
Public class extends
Modified to:
Public class extends Sherlockfragmentactivity
Then follow the dependencies in order Clean:actionbarsherlock, library, examplelistactivity
At this point, a Slidingmenu simple demo has been imported successfully, the following we can see the effect of slidingmenu, if you feel the above steps more trouble, you can download directly I have configured: Click to download [GitHub]
Configuration completed, we need to write some Slidingmenu demo, first for the new project to add the library, the following shows a simple slidingmenu code, only a few lines of code can achieve a simple slidingmenu effect.
1 //Configure the Slidingmenu2Slidingmenu menu =NewSlidingmenu ( This);3 Menu.setmode (slidingmenu.left);4 Menu.settouchmodeabove (slidingmenu.touchmode_fullscreen);5 menu.setshadowwidthres (r.dimen.shadow_width);6 menu.setshadowdrawable (R.drawable.shadow);7 menu.setbehindoffsetres (r.dimen.slidingmenu_offset);8Menu.setfadedegree (0.35f);9Menu.attachtoactivity ( This, slidingmenu.sliding_content);TenMenu.setmenu (R.layout.slide_menu);
The above slidingmenu may be a bit simple, here is my slidingmenu properties of some summary, may not be very complete, if necessary, see the Slidingmenu on GitHub demo;
1 //Configure the Slidingmenu2menu =NewSlidingmenu ( This);3 4Menu.setmode (Slidingmenu.left);//Set left slide menu5 6 //Menu.setmode (slidingmenu.left_right);//property, and then set the layout file for the menu on the right7 //Menu.setsecondarymenu (r.layout.activity_main);8 //menu.setsecondaryshadowdrawable (R.drawable.shadow);//shaded picture on the right menu9 Ten /** One * Set the sliding area A */ -Menu.settouchmodeabove (Slidingmenu.touchmode_fullscreen);//Full screen is available - //Menu.settouchmodeabove (slidingmenu.touchmode_margin);//next to the //Menu.settouchmodeabove (slidingmenu.touchmode_none);//The activity interface is not available . - - - /** + * Shadow - */ +Menu.setshadowwidth (200);//Set Shadow width AMenu.setshadowwidthres (R.dimen.shadow_width);//set the width of a shadow picture atMenu.setshadowdrawable (R.drawable.shadow);//set Shadow Picture - - /** - * Fade in/Fade out - */ -Menu.setfadeenabled (true);//whether to fade in or fade inMenu.setfadedegree (0.35f);//set the scale of the fade - toMenu.setbehindscrollscale (0.2f);//to set the drag effect when sliding +Menu.setbehindwidth (400);//set the width of the Slidingmenu menu -Menu.setbehindoffsetres (R.dimen.slidingmenu_offset);//the remaining width of the main page displayed when Slidingmenu the *Menu.attachtoactivity ( This, slidingmenu.sliding_content);//to attach the slidingmenu to the activity. $Menu.setmenu (R.layout.slide_menu);//to set the layout file for a menuPanax Notoginseng -Canvastransformer Mtransformer =NewCanvastransformer () { the @Override + Public voidTransformcanvas (Canvas canvas,floatPercentopen) { A floatScale = (float) (Percentopen * 0.25 + 0.75); theCanvas.scale (scale, scale, canvas.getwidth ()/2, +Canvas.getheight ()/2); - } $ }; $Menu.setbehindcanvastransformer (Mtransformer);//left or right slide custom animation
Slidingmenu other properties, others have summed up very well, I will not repeat here, if necessary, refer to the following address.
Androidui--slidingmenu Use Example: http://www.cnblogs.com/zhjsll/p/3704552.html
"Android" Slidingmenu properties in detail: http://www.cnblogs.com/SharkBin/p/3665548.html
Android Slidingmenu detailed optimized side-slip: http://blog.csdn.net/aaawqqq/article/details/44121577
In layman Slidingmenu