Tech Stuff: A sliding menu for Android, very much like the Google+ and Facebook apps have it

CoboltForge Berlin  -  Jul 17, 2012  -  12 Comments

Thanks to Stack Overflow and github, we’ve been able to implement a Google+/Facebook-style sliding menu into one of our apps in development. That is, you click on the app icon in the action bar and – swoosh – the whole app slides over to the right, including the action bar, and makes room for a nice scrollable menu with optional image header. Just like Facebook, Google+ and Spotify do! In fact, this kinda menu will maybe be a new de-facto standard for in-app navigation

You can find a library project to include in your app and an example app over at github.

This would not have been possible without the work done by other people, and which we just built upon! The breakthrough idea comes from Stack Overflow user Scrirocco while the XML parsing stuff is to be credited to David Scott and his RibbonMenu! Thanks a lot guys and credit where credit is due!

12 Comments to Tech Stuff: A sliding menu for Android, very much like the Google+ and Facebook apps have it

  1. Darren
    July 26, 2012 05:08

    Hi,

    Thank you for this great library. I was able to make use of it rather easily. I must say that this is the best library for my application and i have looked through 6-7 others because my current app uses greendroid for action bar compatibility with older android versions and this library works just perfectly with the greendroid library. Amazingly simple to use.

    However, as my app needs to support api 8 and above, i have realised that this library did not work on pre honeycomb devices because the view hierarchy appears to be different pre and post honeycomb. it could also just be greendroid alters the view hierarchy for pre and post honeycomb devices differently i am not sure.

    performing findViewById(android.R.id.content).getParent() on post honeycomb devices returns me the linearlayout as expected but on pre honeycomb devices i obtained the PhoneWindow$DecorView instead. Inspecting the viewhierarchy i realised that on pre honeycomb devices there isn’t the linearlayout before the framelayout with id of content so i got a classcastexception.

    What i had to do to make it work for my app was to check if findViewById(android.R.id.content).getParent() is indeed the linearlayout that was expected or if there isn’t any linearlayout then treat the view with id of content as the first view.

    Hope this makes sense.
    Did you face the same problems with pre honeycomb devices?

    Again, thank you very much for the effort. It has helped me tremendously.

  2. CoboltForge Berlin
    August 7, 2012 16:04

    Hi Darren,
    nope, we didn’t face any of these problems (classcastexceptions) with gingerbread, for instance. Some users have reported though that the status bar sometimes overlaps the slide menu. There actually is a fix for that in the code, but it’s not always working. If you got a fix for your issue, would you mind to post a patch against git master? That’d be great!

  3. vortana
    August 22, 2012 08:11

    That’s really great library,..

    How could I change the sliding menu to slide from right to left ?? thx

  4. CoboltForge Berlin
    August 23, 2012 05:41

    Well open an issue on github and we’ll implement it ;-)

  5. swapniladsure
    September 20, 2012 08:21

    Thank for Lib and your Slidemenu works very good. but i face one problem on xperia neo that once you open slide menu if you click on same button for closing the menu it wont close.. i mean it stuck between slide menu and main activity..also can you tell me the way how could i display my view when particular item is selected from list..i am new to development so please help me

  6. CoboltForge Berlin
    September 21, 2012 13:50

    All info on this issue is gathered at https://github.com/bk138/LibSlideMenu/issues/6. Seems you already found that one ;-)

  7. ghouse
    October 8, 2012 07:06

    slidemenu.setHeaderImage(R.drawable.ic_launcher); this line is giving error as methods setheaderimage(drawable )in the type slidemenu is not applicable for the arguments int

  8. CoboltForge Berlin
    October 8, 2012 09:00

    True. It now takes a Drawable.

  9. Alessio
    October 12, 2012 08:52

    Hi,

    Thanks for sharing this great library, I’m actually testing it and you’ve done a really great work!
    It would be fantastic if could be possible to pass a layout to slidemenu.init() instead of an xml, this way could be nice for building a search bar, like facebook app.

  10. CoboltForge Berlin
    November 21, 2012 21:17

    Hi Alessio,
    we’ll look into it, time permitting…

    PS: You can always copy https://github.com/bk138/LibSlideMenu/blob/master/libslidemenu/res/layout/slidemenu.xml into your app and customise it, it’ll override the one given in the library sources!

  11. kshitij
    January 31, 2013 05:39

    Hello,
    I have just gone through the liberary and it works fine but my current need it that i need to open a new activity layout on each list item click like facebook.
    But in other liberaries they are just calling the urls I wonder how could i achieve (opening new activities from every listitem) by using this code in my application. Any help would be appriciable.

  12. CoboltForge Berlin
    January 31, 2013 12:58

    Have an abstract superclass that implements the SlideMenu and then start subclasses via startActivity() ?

Leave a Comment

Your email address will not be published. Required fields are marked *

*