Android to achieve the effect of imitation QQ side Sidebar

Source: Internet
Author: User

Recently saw a project on the sidebar from GitHub, mimicking the QQ sidebar.

The GitHub address is https://github.com/SpecialCyCi/AndroidResideMenu, This project is an Android studio project that can be imported into Android studio or imported into eclipse.

The Residemenu is a third-party control that is written and can be used directly. Let's take a look at how it's used.

 Public classMenuactivityextendsFragmentactivityImplementsview.onclicklistener{PrivateResidemenu Residemenu; Privatemenuactivity Mcontext; PrivateResidemenuitem Itemhome; PrivateResidemenuitem Itemprofile; PrivateResidemenuitem Itemcalendar; PrivateResidemenuitem itemsettings; /*** Called when the activity is first created. */@Override Public voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.main); Mcontext= This;        Setupmenu (); if(Savedinstancestate = =NULL) changefragment (Newhomefragment ()); }    Private voidSetupmenu () {//attach to current activity;Residemenu =NewResidemenu ( This);        Residemenu.setbackground (R.drawable.menu_background); Residemenu.attachtoactivity ( This);        Residemenu.setmenulistener (Menulistener); //valid scale factor are between 0.0f and 1.0f. Leftmenu ' width is 150dip.Residemenu.setscalevalue (0.6f); //create menu items;Itemhome =NewResidemenuitem ( This, R.drawable.icon_home, "home"); Itemprofile=NewResidemenuitem ( This, R.drawable.icon_profile, "profile"); Itemcalendar=NewResidemenuitem ( This, R.drawable.icon_calendar, "Calendar"); Itemsettings=NewResidemenuitem ( This, R.drawable.icon_settings, "settings"); Itemhome.setonclicklistener ( This); Itemprofile.setonclicklistener ( This); Itemcalendar.setonclicklistener ( This); Itemsettings.setonclicklistener ( This);        Residemenu.addmenuitem (Itemhome, residemenu.direction_left);        Residemenu.addmenuitem (Itemprofile, residemenu.direction_left);        Residemenu.addmenuitem (Itemcalendar, residemenu.direction_right);        Residemenu.addmenuitem (Itemsettings, residemenu.direction_right); //You can disable a direction by setting//residemenu.setswipedirectiondisable (residemenu.direction_right);Findviewbyid (R.id.title_bar_left_menu). Setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (view view) {Residemenu.openmenu (residemenu.direction_left);        }        }); Findviewbyid (R.id.title_bar_right_menu). Setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (view view) {Residemenu.openmenu (residemenu.direction_right); }        });}

The Residemenuitem is the option in our sidebar, where four options are created, and the control has a left-right sidebar effect that allows you to swipe left and right. Of course we can also set options to appear in the right sidebar. The Residemenu.addmenuitem is called to set the side bar to display.

each option can be used to display different fragment. This open source project is still very good, is a more popular side bar style.

If you have any questions, you are welcome to communicate with me. to learn more about the students, you can click to view the source code , personally run the experience!

Jerry Education
Source:http://www.cnblogs.com/jerehedu/
This article is the copyright of Yantai Jerry Education Technology Co., Ltd. and the blog Park is shared, welcome reprint, but without the consent of the author must retain this paragraph statement, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.

Android to achieve the effect of imitation QQ side Sidebar

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.