Slidingmenu to implement app slide-off function

Source: Internet
Author: User

Many apps have the ability to slide the menu, some apps are side-slip menu ~slidingmenu This open source project can help us to realize the slide-off function, if the slidingmenu is not very familiar with children's shoes, you can refer to this blog.

This blog is just slidingmenu simple usage for beginners to use, thank you for your support.

First, we have to pilot a third-party package: Slidingmenu.jar

Go to Code now

On this homepage activity_main.xml is not showing the individual needs

This is the side-drop display layout see personal Display page layout (for reference only)/jinritioutiao/res/layout/left_cela.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"
android:orientation= "Vertical" >
<relativelayout
Android:layout_width= "Match_parent"
android:layout_height= "100DP"
Android:background= "#fff3f3f3"
>

<imageview
Android:id= "@+id/cela_shouji"
Android:layout_width= "50DP"
android:layout_height= "50DP"
Android:layout_alignparentleft= "true"
Android:layout_centervertical= "true"
android:layout_marginleft= "22DP"
android:background= "@drawable/cellphoneicon_login_profile_normal"/>

<imageview
Android:id= "@+id/cela_qq"
Android:layout_width= "50DP"
android:layout_height= "50DP"
android:layout_aligntop= "@+id/cela_shouji"
Android:layout_centerhorizontal= "true"
android:background= "@drawable/ic_qq_login_normal"/>

<imageview
Android:id= "@+id/cela_weibo"
Android:layout_width= "50DP"
android:layout_height= "50DP"
Android:layout_alignparentright= "true"
android:layout_aligntop= "@+id/cela_qq"
android:layout_marginright= "14DP"
android:background= "@drawable/ic_weibo_login_normal"/>

<textview
Android:id= "@+id/genduofangsi"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_alignparentbottom= "true"
Android:layout_alignparentleft= "true"
android:text= "More ways to sign in >>>"/>

</RelativeLayout>
<listview
Android:id= "@+id/ce_listview"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"

android:layout_weight= "1"
></ListView>
<relativelayout
Android:layout_width= "Match_parent"
android:layout_height= "100DP"
Android:background= "#fff3f3f3"
>

<textview
Android:id= "@+id/cela_xiazaitext"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_alignleft= "@+id/cela_xiazai"
android:layout_below= "@+id/cela_xiazai"
android:text= "Offline Download"

Android:textsize= "12DP"/>

<imageview
Android:id= "@+id/cela_yejian"
Android:layout_width= "40DP"
android:layout_height= "40DP"
Android:layout_above= "@+id/cela_xiazaitext"
Android:layout_centerhorizontal= "true"
android:background= "@drawable/nighticon_leftdrawer_normal"/>

<textview
Android:id= "@+id/cela_yejiantext"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_alignleft= "@+id/cela_yejian"
android:layout_below= "@+id/cela_xiazai"
android:text= "Night Mode"
Android:textsize= "12DP"/>

<imageview
Android:id= "@+id/cela_shezhi"
Android:layout_width= "40DP"
android:layout_height= "40DP"
Android:layout_above= "@+id/cela_yejiantext"
Android:layout_alignparentright= "true"
android:layout_marginright= "22DP"
android:background= "@drawable/settingicon_leftdrawer_normal"/>

<imageview
Android:id= "@+id/cela_xiazai"
Android:layout_width= "40DP"
android:layout_height= "40DP"
Android:layout_alignparentleft= "true"
Android:layout_centervertical= "true"
android:layout_marginleft= "24DP"
android:background= "@drawable/downloadicon_leftdrawer_normal"/>

<textview
Android:id= "@+id/cela_shezhitext"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_alignbaseline= "@+id/cela_yejiantext"
Android:layout_alignbottom= "@+id/cela_yejiantext"
android:layout_alignleft= "@+id/cela_shezhi"
android:text= "Quick Setup"
Android:textsize= "12DP"/>

</RelativeLayout>
</LinearLayout>

Next, in the home/jinritioutiao/src/com/bawei/jinritioutiao/mainactivity.java, hit

Side Pull
Final Slidingmenu menu=new Slidingmenu (this);
Menu.setmode (slidingmenu.left);//Set menu slide mode, menu appears on left side left_right right side
Menu.settouchmodeabove (Slidingmenu.touchmode_margin);//Set the area of the slide this is the edge touchmode_fullscreen this setting to full screen area can be sliding touchmode_ None cannot slide
Menu.setshadowdrawable (R.drawable.shadow);//Set Shadow Picture
Menu.setsecondaryshadowdrawable (r.drawable.shadowright);//Shadow picture on right menu
Menu.setshadowwidthres (r.dimen.shadow_width);//Set the width of the shadow picture
Menu.setbehindwidth (300);//Side Pull page width
Menu.setbehindoffsetres (R.dimen.slidingmenu_offset); the remaining width displayed on the main page when//slidingmenu
Menu.setbehindoffset (150);//The remainder of the page width
Menu.setfadedegree (0.35f);//The degree of gradient when sliding
Menu.attachtoactivity (this,slidingmenu.sliding_content);//enable Slidingmenu to be attached to activity
Menu.setsecondarymenu (r.layout.menu_frame2);//Set Right menu
Menu.setmenu (R.layout.left_cela);//Set Layout file on left menu
This is to give the main page a control to listen let him click on the Show Side drop menu
Tiouxiang.setonclicklistener (New Onclicklistener () {

@Override
public void OnClick (View v) {
TODO auto-generated Method Stub
Click Show Side Drop Menu
Menu.showmenu ();
}
});

Slidingmenu to implement app slide-off function

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.