Third-party slide-through menu Slidingmenu in Android Studio

Source: Internet
Author: User

Southern dust: A little progress every day!

In front of the official slide menu drawerlayout use, in fact, before the official launch of this, there are many third-party jar packages such as slidingmenu, etc., thanks to the power of open source.

Slidingmenu is an open-source, side-by-side menu (Https://github.com/jfeinstein10/SlidingMenu). This feature is also useful for providing a side-slip menu for everyone's Android program.


Configuration:
I test using a third-party jar package under Eclipse can be used normally, and under Andorid Studio directly import jar package into the app will report a what index out of bounds of the exception, so through the multi-data to understand that this should be configured.

1) Download the zip archive from GitHub and unzip it. The library folder inside is what we need.

2) Import dependent libraries

3) switch to Project view and open the Build.gradle under the app with the Build.gradle under the library respectively. The library under the Gradle version of the revision with the native version of the match, the native version of the root directory Build.gradle view attention to distinguish!

4) Don't forget you also need the app click the right mouse button to open the module setting add dependencies, in fact, these things you can change in the configuration file. But I prefer to use the mouse to point.

Well, here, our Slidingmenu library has been successfully imported into the app we wrote. The following can be called successfully.

On the run diagram:

On the code:

Package Com.example.nanchen.slidingmenudemo;import Android.os.bundle;import Android.support.v7.app.appcompatactivity;import Com.jeremyfeinstein.slidingmenu.lib.slidingmenu;public Class Mainactivity extends Appcompatactivity {@Override protected void onCreate (Bundle savedinstancestate) {Super        . OnCreate (Savedinstancestate);        Setcontentview (R.layout.activity_main);        Configure the Slidingmenu slidingmenu menu = new Slidingmenu (this);        Menu.setmode (Slidingmenu.left);        Set the touch screen mode menu.settouchmodeabove (Slidingmenu.touchmode_fullscreen);        Menu.setshadowwidthres (R.dimen.shadow_width);        Menu.setshadowdrawable (r.color.coloraccent);        Sets the width of the Slide menu view menu.setbehindoffsetres (R.dimen.slidingmenu_offset);        Sets the value of the Fade Out Effect Menu.setfadedegree (0.35f); /** * Sliding_window would include the Title/actionbar in the content * sections of the Slidingmenu, while S         Liding_content does not. */        Menu.attachtoactivity (this, slidingmenu.sliding_content);    Set the layout Menu.setmenu (R.layout.left_menu) for the side-slip menu; }}

  

Activity_main

<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout    xmlns:android= "http://schemas.android.com/apk /res/android "    xmlns:tools=" Http://schemas.android.com/tools "    android:layout_width=" Match_parent    " android:layout_height= "Match_parent"    android:paddingbottom= "@dimen/activity_vertical_margin"    android: paddingleft= "@dimen/activity_horizontal_margin"    android:paddingright= "@dimen/activity_horizontal_margin"    android:paddingtop= "@dimen/activity_vertical_margin"    tools:context= " Com.example.nanchen.slidingmenudemo.MainActivity ">    <textview        android:layout_width=" wrap_content "        android:layout_height=" wrap_content "        android:text=" Hello world! " /></relativelayout>

Left_menu.xml

<?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 ">    <listview        android:background= "#2c90c9"        android:layout_width= "match_parent"        android:layout_height= "Match_ Parent ">    </ListView></LinearLayout>

  

<dimen name= "Slidingmenu_offset" >60dp</dimen>
<dimen name= "Shadow_width" >15dp</dimen>

Third-party slide-through menu Slidingmenu in Android Studio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.