Jeff Lee blog:http://www.cnblogs.com/alandre/(Mud brick Carpenter), retain the URL when reproduced! Thanks
:
Resources to the top of the first page Add group can.
I. Slidingmenu INTRODUCTION
Github:https://github.com/jfeinstein10/slidingmenu
On the official website, the above description is translated:
Slidingmenu is an open source Android library that makes it easy for developers to develop a sliding menu app (like Google+,youtube,facebook). By introducing the license code for this open source library, you can easily use the app that you want to swipe the menu for free. As shown in the following:
Two. Official Small example
public class Slidingexample extends Activity { @Override public void OnCreate (Bundle savedinstancestate) { Super.oncreate (savedinstancestate); Settitle (R.string.attach); Set the content view Setcontentview (r.layout.content); Configure the Slidingmenu slidingmenu menu = new Slidingmenu (this); Menu.setmode (slidingmenu.left); Menu.settouchmodeabove (slidingmenu.touchmode_fullscreen); Menu.setshadowwidthres (r.dimen.shadow_width); Menu.setshadowdrawable (R.drawable.shadow); Menu.setbehindoffsetres (r.dimen.slidingmenu_offset); Menu.setfadedegree (0.35f); Menu.attachtoactivity (this, slidingmenu.sliding_content); Menu.setmenu (R.layout.menu); }}
Naturally you can also define a slidingmenu with XML
<com.jeremyfeinstein.slidingmenu.lib.slidingmenu xmlns:sliding= "Http://schemas.android.com/apk/res-auto " android:id=" @+id/slidingmenulayout " android:layout_width=" fill_parent " android:layout_height=" Fill_parent " sliding:viewabove=" @layout/your_above_view " sliding:viewbehind=" @layout/your_behind_ BEHIND " sliding:touchmodeabove=" Margin|fullscreen " sliding:behindoffset=" @dimen/your_offset " Sliding:behindwidth= "@dimen/your_width" sliding:behindscrollscale= "@dimen/your_scale" sliding: shadowdrawable= "@drawable/your_shadow" sliding:shadowwidth= "@dimen/your_shadow_width" sliding: Fadeenabled= "True|false" sliding:fadedegree= "float" sliding:selectorenabled= "True|false " sliding:selectordrawable= "@drawable/your_selector"/>
The official documents are translated as follows:
viewAbove-layout Reference on top of menu
viewBehind-Layout reference below the menu
touchModeAbove-refers to that part of the screen touch rear view display
behindOffset-How much the body displays when the menu is displayed (per pixel)
behindWidth-the menu shows the width of the main display. Default Full Screen
behindScrollScale-Scrolling settings for menu display
shadowDrawable-Scrolling Shadow Settings
shadowWidth-Width of scrolling shadow
fadeEnabled-whether the menu is gradient when sliding
fadeDegree-degree of gradient when sliding
Three. Implement the sliding menu
Main structure: Mainact as the main entrance, then each fragment to achieve their respective content action.
Mainact.java
public class Mainact extends fragmentactivity {private Slidingmenu menu; @Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.slidingmenu_main); menu = new Slidingmenu (this); Menu.settouchmodeabove (Slidingmenu.touchmode_fullscreen); Menu.setshadowwidthres ( R.dimen.slidingmenu_shadow_width); menu.setshadowdrawable (R.drawable.slidingmenu_shadow); Menu.setbehindoffsetres (r.dimen.slidingmenu_offset);D isplaymetrics dm = new Displaymetrics (); GetWindowManager (). Getdefaultdisplay (). Getmetrics (DM); Menu.setfadedegree (0.35f); Menu.setbehindoffset (dm.widthpixels*50/100); Menu.attachtoactivity (this, slidingmenu.sliding_content); Menu.setmode (slidingmenu.left_right);//Here the mode is set to the left and right menu, Right menu is displayed, left menu is displayed, Left_righ menu is displayed menu.setcontent (r.layout.slidingmenu_content); Menu.setmenu ( R.layout.slidingmenu_menu); Menu.setsecondarymenu (r.layout.slidingmenu_menu_2); Menu.setsecondaryshadowdrawable ( r.drawable.slidingmenu_shadow_2); Getsupportfragmentmanager (). BeginTransaction (). Replace (r.id.slidingmenu_content, new Mainfragment (menu) ). commit ();//Set Main Page Content Getsupportfragmentmanager (). BeginTransaction (). Replace (R.id.slidingmenu_menu, new Mainleftfragment ()). commit ();//Set left menu contents Getsupportfragmentmanager (). BeginTransaction (). Replace (r.id.slidingmenu_ Menu_2, new Mainrightfragment (menu)). commit ();//Set Right menu contents}}
Summary: The use of simple is difficult
Android UI (iii) SLIDINGMENU implementation Sliding menu (detail official)