For example, please view this image from the Android Developers site.
Basically, I want to replicate this navigation drawer, currently I have it all except the sub items (Option 1, Option 2, in the example). There is no documentation on how to get this on the developers site. This is what I have currently:
MainActivity.java: http://pastebin.com/iNXW00ex
SeparatedListAdapter.java: http://pastebin.com/fESuvEVi
MainActivity.xml: http://pastebin.com/gg4JANwh
Drawer Item/Header.xml: http://pastebin.com/WzvPXQYm
That's all I think is needed. I'm aware that typically a expandable list view is used for the child items, though I'm unsure how to combine that with the current separated list adapter so I can still get titles.
Thanks, David.
There are a lot of third party libs for sliding menus.
Why not use one of them instead of trying to recreate Android's?
For example:
https://github.com/jfeinstein10/SlidingMenu
Have you checked out the Navigation Drawer tutorial in the Android docs?
http://developer.android.com/training/implementing-navigation/nav-drawer.html
Uses classes in the support library to make implementing the nav drawer pretty straightforward.
Related
I have made my navigation drawer and it is working all fine , it is according to new design rules. but now I have a problem and after a couple of search I have found no note over it so far. So I end up with asking question here.
What I have done so far is some thing like
the picture shows you the demo , How ever I have made some thing like this its just the demo to give you people hint about what is header in the navigation drawer and where my menu items list lies
You can clearly see that there is a header in the navigation drawer and the menu item list beneath it .
Problem 1
now do to some reasons I have deleted the header , but my menu Items goes upwards to the top starting point. I know I can give margin up , but this is not the good way
Is there any good way I can just centralized them vertically ? I am wondering How to do it , Please Help me .
and Problem 2 is , I want to minimize the distance and margin between the menu items and menu icons in navigation drawer How to do this. I have not seen any of the discussion over it.
Please help me in solving both problems.
On screenshot you attached to your question, the navigation drawer doesn't look fine and according to the new desing rules :-/
Just have a look at the official guide: https://www.google.com/design/spec/patterns/navigation-drawer.html
Luckly for you nowdays we are provided by Google with Android Design Support Library that helps us with creating Navigation View (that replaces Navigation Drawer)
Here are links for you:
official documentation, always a good read: https://developer.android.com/reference/android/support/design/widget/NavigationView.html
nicely written blog post about Navigation View: http://antonioleiva.com/navigation-view/
and last but not least, sample app using new Android Design Library: https://github.com/antoniolg/MaterializeYourApp
I know it's not the answer you were looking for, like "just change true to false in the line number 10" but stay assured that using official Navigation View is a way to go in modern Android world.
You can use the new NavigationView from the Android Design Support Library in making your navigation drawer. NavigationView make s creating material design-compliant navigation drawer.
You can read about it at http://android-developers.blogspot.com/2015/05/android-design-support-library.html
Read these three articles
Take a look at this code
Use the design support library
I would like to implement a custom navigation drawer (such as the one shown here) and I have been trying all kinds of navigation menu libraries for Android and iOS but haven't come up with a good option. Is there any library that could achieve this kind of navigation or does anyone have any idea how this could be done as a custom component?
You can try SlidingMenu. Its one of the most widely used alternatives for navigation drawer. Its gives you a whole host of options which are listed on their homepage.
First
Second
Second I used before and it is nice as for me, but first one looks more promising.
Happy coding :)
How to implement android navigation drawer like this?
TopLevelView1 ~ TopLevelView4 can select and no children
TopVevelView5 can collaspe
My question is that if my group structure like this for example
All
Stared
Category
----mp3
----txt
----doc
----pdf
when I select all then show all file.
when I select stared then show stared file only.
when I select mp3 then show only mp3 files.
and Category can expand and collapse.
For navigation:
Alternative 1:
Sliding Menu, which I would definitely go with. Even used by popular application like LinkedIn and Foursquare and easy to implement and use. Full explanation and example source codes: SlidingMenu - GitHub
Alternative 2:
Android Navigation Drawer. If you want to fully customise everything yourself without using any libraries, this is your option. You can check codes and how to do it from Android Developers website: Creating a Navigation Drawer
View inside your navigation drawer / sliding menu:
Alternative 1:
Android default ExpandableListView. Links: Android Developers , androidhive
Alternative 2:
AnimatedExpandableListView, which is implemented from ExpandableListView, but when an item is clicked, the expand is done with a smooth animation which you may prefer to use for a better look. AnimatedExpandableListView
I need to incorporate a youtube like drawer navigation drawer for both(left,right) sides. AFAIK android apis don't provide means for the right-to-left drawer functionality. There're quite a lot of implementations out there(sliding menu) which do.
This sliding menu feature seems to present a performance issue. Should I try to rewrite original NavigationDrawer, which I expect to be the least performance-impact solution, or there is another performance-optimal library?
Thanks.
I would choose NavigationDrawer. I used both and I find NavigationDrawer smoother. If you try to mimic google UX then with NavigationDrawer should be enought for your needs.
I recently made a project/demo to implement NavigationDrawer with ActionBarSherlock for pre Honeycomb devices because I need for an app.
SherlockNavigationDrawer impl
Another thing to take in mind is that if you use NavigationDrawer try to avoid Tabs because all the tabs items could fit perfectly as a listview in NavigationDrawer.
Actually NavigationDrawer supports drawers on both edges.
You have to supply the two drawer views inside your layout xml; one with gravity:left and one with gravity:right.
Then, in your Activity you call setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED) on your DrawerLayout object.
This will enable swiping either from left or right edge.
#MichaĆ The question is actually implementation of both left as well as the right drawer.
#midnight NavigationDrawer right now only implements one-sided menu which you can place either on the left or the right. If you want to implement the other pane also you can make your content layout as SlidingPaneLayout.
This was also added to the latest support library along with the NavgationDrawer. For an implemented example you can look at the newest Hangouts app on how they are using it. This layout will probably suit your purposes better rather than rewriting the NavigationDrawer. In any case i'd hold off on re-writing it since it is the first release of the Layout and may undergo changes fairly quickly.
Since the last version of SupportLibrary there is a NavigationDrawer in Android.
I don't think these examples use viewpager, but visually they look a little like viewpager.
See Evernote's settings:
http://1.androidauthority.com/wp-content/uploads/howto/evernote-screenshots-120524.jpg
And Pocket Casts' handheld control pane:
http://www.shiftyjelly.com/android/pocketcasts
Basically, a panel is swiped in from left, but the left edge of the previous panel is still visible.
So my question is, is this UI pattern featured in an example you have seen, or did these two make it out of whole cloth and now I have to, too?
Edit for posterity:
As of Google I/O 2013, this is now built into Android. They call it the Navigation Drawer: http://developer.android.com/training/implementing-navigation/nav-drawer.html
https://github.com/jfeinstein10/SlidingMenu
This library might help you out. I think this is what you're trying to achieve.
EDIT
I've updated the link to another SlidingMenu library but as of 2015/09/16, I wouldn't use the library referenced here anyway. Google has provided the DrawerLayout in the v4 support library to achieve this. Inside the drawer, for a more standard structured navigation, the design support library has also provided the NavigationView that can be placed inside the DrawerLayout and use standard menu resource to inflate the items contained within. This SO can help out with the details of the implementation.