Many Android apps now have a sideslip menu that works fine.
There is a Slidingmenu open source Library on the GitHub, which is convenient to use.
Slidingmenu GitHub Address: Https://github.com/jfeinstein10/SlidingMenu. GitHub said that the sliding combined actionbarsherlock function can be richer, actionbarsherlock GitHub address: Https://github.com/JakeWharton/ActionBarSherlock
Attached CSDN Download Address:
slidingmenu:http://download.csdn.net/detail/lanximu/7922377
actionbarsherlock:http://download.csdn.net/detail/lanximu/7922383
Below, introduce the use of the next slidingmenu.
(1) from the GitHub on the download zip to the local, decompression, get one of the folders, library.
(2) Eclipse import Existing Android Code into Workspace. Click the item right key properties->android, you can see, its is Library.
(3) In the project will use Slidingmenu the right mouse button properties->android,library under (2) imported items into.
(4) In order to ensure the success of the Slidingmenu Library application to the project, it is necessary to ensure that the Libs and slidingmenu libraries used in the project are consistent with the Libs version, mainly referring to Android-support-v4.jar. If the project Libs does not exist or the compilation does not pass, you can try creating a new Libs folder and placing the Android-support-v4.jar. Right-->build Path->use as Source on the Libs. Can generally be solved.
(5) after step (4), Slidingmenu can be used directly in the project.
Java code:
Mainactivity:
Copy Code code as follows:
Package com.jj.testslidingmenu;
Import Com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
Import Android.os.Bundle;
Import android.app.Activity;
Import android.view.KeyEvent;
Import Android.view.Menu;
public class Mainactivity extends activity {
Slidingmenu Slidingmenu;
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Slidingmenu = new Slidingmenu (this);
Slidingmenu.setmode (Slidingmenu.left);
Slidingmenu.settouchmodeabove (Slidingmenu.touchmode_fullscreen);
Slidingmenu.setbehindoffsetres (R.dimen.slidingmenu_offset);
Slidingmenu.setmenu (R.layout.slidingmenu);
Slidingmenu.attachtoactivity (this, slidingmenu.sliding_content);
}
@Override
public boolean onKeyDown (int key, KeyEvent event) {
Switch (key) {
Case Keyevent.keycode_menu:
Slidingmenu.toggle (TRUE);
Break
Default
Break
}
return false;
}
}
XML Layout Code:
Layout/slidingmenu.xml:
Copy Code code as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical"
android:background= "#ff999999" >
<com.jeremyfeinstein.slidingmenu.lib.slidingmenu
Android:id= "@+id/slidingmenu"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
>
<button
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
Android:text = "click me"/>
</com.jeremyfeinstein.slidingmenu.lib.SlidingMenu>
</LinearLayout>
Some of the property settings that are commonly used for Slidingmenu are recorded as follows:
Menu.setmode (slidingmenu.left);//Set Left sliding menu
Menu.settouchmodeabove (Slidingmenu.touchmode_fullscreen)//Set sliding screen range, which can slide in full screen area
Menu.setshadowdrawable (R.drawable.shadow);//Set Shadow Picture
Menu.setshadowwidthres (r.dimen.shadow_width);//Set the width of the shadow picture
Menu.setbehindoffsetres (R.dimen.slidingmenu_offset); the remaining width of the main page displayed when the//slidingmenu is drawn
Menu.setbehindwidth (400);//Set Width of slidingmenu menu
Menu.setfadedegree (0.35f);//slidingmenu the degree of gradual sliding
Menu.attachtoactivity (this, slidingmenu.sliding_content);//make slidingmenu attached to activity
Menu.setmenu (r.layout.menu_layout);//Set Menu layout file
Menu.toggle ()//dynamic judgment automatically closes or opens Slidingmenu
Menu.showmenu ()//Display Slidingmenu
Menu.showcontent ()//display content
Menu.setonopenlistener (Onopenlistener)//Listening Slidingmenu Open
Menu.setonopenedlistener (Onopenedlistener); listening Slidingmenu Open
Menu. Oncloselistener (Onclosedlistener)//monitoring Slidingmenu Shutdown Event
Menu. Onclosedlistener (Onclosedlistener)//monitor Slidingmenu event after shutdown
Can be left or right to draw the Slidingmenu menu only need to set
Menu.setmode (slidingmenu.left_right); properties, and then set the layout file for the right menu
Menu.setsecondarymenu (R.LAYOUT.MENU_FRAM2)//Set Right menu
Menu.setsecondaryshadowdrawable (r.drawable.shadowright);//Shadow Picture of right menu