I really want to implement this (the side navigation) in an app of my own, does anyone know how Google managed to do this?
They seem to have pulled the current window aside and put in a fly-in navigation of their own.
I really want to implement this (the side navigation) in an app of my own, does anyone know how Google managed to do this?
They seem to have pulled the current window aside and put in a fly-in navigation of their own.
Did a roundup of the original implementation and added XML parsing as well as
autodetection
of a possibly presentactionbar
, so it works with the native as well as a support action bar such asActionBarSherlock
.The whole thing is now a library project together with an example app and is described over at Sliding Menu for android Thanks to scirocco for the initial idea and code!
For those of you who uses the SlidingMenu library (https://github.com/jfeinstein10/SlidingMenu) there is a way to jack it in and it seems to work! With help of @Scirocco put this in your
onCreate
for the activity:basically what it does is replacing the
linearlayout
in decor view with theslidingmenu
instead.Notice: Ive only tested it lightly but it seems to work.
In fact, there's a way to do this. Even without implementing your own
ActionBar
.Just have a look at the
hierachyviewer
! (Located in the tools directory)There's the
DecorView
, and aLinearLayout
as a child. ThisLinearLayout
contains both theActionBar
and the other content. So, you can simply apply someFrameLayout.LayoutParams
to thisLinearLayout
and get some space on the left side this way. Then, you can fill this space with your menu-ListView and overlay the other content with a FrameLayout, that, when it's clicked, collapses the menu. So, here's some code:First, the class for collapsing / expanding (SlideMenu.java):
Some helping methods (for me, in static Functions.java):
Then, the layouts:
Layout of the menu (res/layout/menu.xml)
Layout of the listitems (res/layout/menu_listitem.xml):
How to use it:
In your
onCreate()
:In the handler for your ActionBar homebutton:
That's it!
And now, a little screenshot of it in action:
As far as I know, it is working. If you experience any problems or my explanations are not clear, please contact me!
EDIT:
ExtendedViewPager
&ExtendedPagerStrip
:ExtendedViewPager:
ExtendedPagerTabStrip:
I use this
SlideMenu
for an Activity with aViewPager
withPagerTabStrip
for tabs like Talk, Market etc. You can't disable these Views in an easy way, so the two classes above just extend them to stop theonTouch
event when disabled.There are several attempts at doing this, however I have yet to find a lib or source code on how to implement it successfully with actionbar accross all api levels. One promising lib is here
https://github.com/jfeinstein10/SlidingMenu
here is a video of the example app.
here is the Google Play app link.
This does work with ActionbarSherlock. You will have to build the SlidingMenu library with ABS to get it working. Works and looks great!
this is my class extends
SlidingPaneLayout
. Can slide with actioI've created my own solution for sliding away the view and revealing a menu underneath, as many other solutions appeared to not work on older Android versions or lacked proper instructions on how to get it to work.
My solution has the following features:
The solution uses a custom layout, called SlidingMenuLayout, that you are expected to add 2 views to. The first view you add is the menu, the second is the main view.
The simplest way to add the layout to your existing project is to override your Activity's
setContentView()
method:In this example,
MenuView
is the view that will actually show the menu. It is up to you to implement this view.Finally, you can add a button (typically in the top left corner of your main view), that calls
openMenu()
orcloseMenu()
on the layout as appropriate.The code for
SlidingMenuLayout
is found on the GitHub project page.