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. |
|||||||||||||||||||
|
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 a LinearLayout as a child. This LinearLayout contains both the ActionBar and the other content. So, you can simply apply some FrameLayout.LayoutParams to this LinearLayout 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 a ViewPager with PagerTabStrip 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 the onTouch 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! |
|||||||
|
Did a roundup of the original implementation and added XML parsing as well as autodetection of a possibly present actionbar, so it works with the native as well as a support action bar such as ActionBarSherlock. The whole thing is now a library project togther with an example app and is described over at Sliding Menu for android Thanks to scirocco for the initial idea and code! |
|||||||||||||
|
If you are using API level greater that 11 you can use a much simpler approach inspired by the answer given by @Scirocco
The idea here is to use ValueAnimator that transforms and not just animates the main layout with the Action bar, so you can interact with the inflated view you want to use as a sliding panel. You should replace the hardcoded values with something that is of use to your app. I hope this helps :) |
|||
|
I'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() or closeMenu() on the layout as appropriate. The code for SlidingMenuLayout is found on the GitHub project page |
|||||
|
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 the slidingmenu instead. Notice: Ive only tested it lightly but it seems to work. |
|||
|
Well currently im working on a project and came across Sliding menu,i googled but gets very disappointed to see that no one has given some piece of code or some hint for how to start making a sliding menu,but every one has given link to some github's projects/libraries to use,I decided to do it myself and finally i have my own Sliding Menu Ready... I have Spent two days on it 1. on making animations of sliding 2. on making it work with all screen resolutions Its really easy and simple once you get some idea about Animations, i have read some where,its not sensible to re-invent the Wheel(people who are refering to github source code of sliding menu),but i beleif that you should atleast once try to make your own so you get a idea how it actually works and functions :P so this is a picture of how my sliding menu will going to work 1.Find.xml
2.Filter.xml
In find.xml i have included filter.xml initially which is invisible Now FilterAnimation.java
Now Find.java
Here are the animations res/anim 1.filter_slide_in.xml
2.filter_slide_out.xml
3.other_slide_in.xml
4.other_slide_out.xml
There you go a complete working and functional Sliding Menu, and you can customized it to meet your requirements,if any one still have some problems setting up,feel free to ask,i feel pleasure to help you out :) |
|||||||||
|