Previous article we learned how to configure the Android Studio Slidingmenu
Let's learn how to use Slidingmenu
The use of Slidingmenu is very simple
You only need to add the following in the OnCreate method:
1 slidingmenu = new Slidingmenu (this); 2 Slidingmenu.setmode (slidingmenu.left); 3 slidingmenu.setbehindoffsetres (r.dimen.sliding_menu_offset); 4 Slidingmenu.settouchmodeabove (slidingmenu.touchmode_fullscreen); 5 slidingmenu.attachtoactivity (this, slidingmenu.sliding_content); 6 Slidingmenu.setmenu (R.layout.slidingmenu);
and creating a layout file:
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent"5 Android:background= "@color/color_sliding_menu"6 android:orientation= "vertical">7 8 9 <ButtonTen Android:layout_width= "Wrap_content" One Android:layout_height= "Wrap_content" A Android:text= "click me" - android:layout_gravity= "Center_horizontal" /> - the <Com.jeremyfeinstein.slidingmenu.lib.SlidingMenu - Android:id= "@+id/slidingmenu" - Android:layout_width= "Wrap_content" - Android:layout_height= "Match_parent" + Android:background= "@color/coloraccent"> - + </Com.jeremyfeinstein.slidingmenu.lib.SlidingMenu> A at </LinearLayout>
It's basically done.
On the following:
If you want to know more about Navigationview and drawerlayout, you can continue reading my blog post.
Using Slidingmenu for Android side-by-side menu effects