I understand that to display the sliding menu you must use menu.setBehindWidth(380); to toggle how much you want the menu to slide out. But this works really bad if using multiple device screens. Is there a wrap content kind of thing for this menu? Thanks
Related
I need to develop a fixed left side menu for an Android app that will only be used maximized on Chromebooks. What would be the best strategy in order to create a left side menu that is always visible and expanded (that is, that does not open/close or overlay the content in a drawer), something like the Google Play app has in the image? On the right hand side the app should load one fragment or another depending on the menu item selected. Do I need to develop a custom layout and implement the master/detail logic myself, or is there there some standard flow/mechanism I should rather use or adapt for this?
Thanks in advance.
as I pursue my study on android app development I came across this app from apple and I was wondering if, is there a way to imitate the navigation drawer in this screen shot?!
See it's an expandable navigation drawer. a list view with some items that are expandable. Is there an actual way to imitate this on android?
Thank you very much again for all of your help.
You can recreate that drawer.
You can use the ExpandableListView within the Navigation Drawer. And of course you'll have to create your own parent and child item layouts for the listview. As well as appropriate styling. You can use tutorials to do this, first create the navigation drawer, then create the expandablelistview and put it within the navaigation drawer layout.
I'd also like to note on that screen shot, the drawer is incorrect. It should slide out below the action bar, over-top of the activity (like in the link). It should not slide the entire application window to the right like how some apps do.
Use a Custom ListView for this, see here for that: How To Create A Custom Listview - Android Example
Also, you will have to create specialized buttons that have a different look than standard holo buttons, see here for that: How to create custom button in Android using XML Styles
Finally, I do not believe it is possible to directly clone the navigation drawer, as the app you showed doesn't have an open sourced app (as far as I know).
I have a project where the designs require a sliding drawer that comes from the bottom and has essentially three states.
fully collapsed (just the handle at the bottom
half mast (drawer opens from bottom but only halfway up the screen
full mast (drawer opens from bottom and takes up the whole screen minus a top margin of lets say 80dp
I am developing for android 4.0 and higher and obviously sliding drawer is deprecated. But the Navigation drawer only supports left and right (which i already have in use)
So i am wondering if anyone knows a tutorial or even a custom component someone has written that meets the above functionality requirements
In my experience, you probably have to create something yourself, but since you're developing for api lvl 14, check out ObjectAnimator. It allows you to move Views around and still use them (by that I mean that it's the original view that has been moved and not a copy of it)
This will probably be the easiest way.
FYI, using the Navigation Drawer, you can't open the drawer halfway, or you should programmatically invoke touch events...
I think this is what you are looking for.
I have found this library best so far for sliding up menus in Android.
https://github.com/umano/AndroidSlidingUpPanel
You can specify what screen area slide up menu or view will use.
Accept & vote up my answer if it is what you are looking for.
I'm using the slide menu library and setting the menu offset from a xml.
setBehindOffsetRes(R.dimen.slidingmenu_offset);
when I click the menu item I use
menu.toggle(true);
which moves the content to left with menu behind it. My scenario is when I click the menu item, the content has to move all the way to right and then should bring the content in like the normal way so that the user dont get to see the UI change. I used
setBehindOffsetRes(R.dimen.slidingmenu_fullscreen);
showMenu(true);
where R.dimen.slidingmenu_fullscreen = 0dp. The menu goes to full screen behind the content, but the content doesn't moves to the right. Thanks in advance!
Edit 1: This is similar to Xoom application... Sample "Slide Sample"
I would recommend using ActionBarSherlock. Use this tutorial for sliding menu, It is much easier to use, and you will find much more help with it. It is also more compatible with different screen sizes, and more Android versions.
Finally I figured it myself.
menu.mViewAbove.scrollTo(menu.mViewAbove.getScrollX()-200,0);
moved the content to right. But now got into another problem. which I have descibed here->
https://stackoverflow.com/questions/19714871/sliding-menu-move-content-to-right
The SlidingMenu library is an excellent third party library and I've already used it for a long time. Now I know Android provides a new navigation pattern using Navigation Drawer. It looks like the sliding menu. So is there anyone who already uses these two both? What is the difference and what are the pros and cons? Thanks a lot.
SlidingMenu library is a third party api which uses a RelativeLayout inside. The main advantage is customization according to your requirement. Buy your layouts have to be based on a viewgroup, unfortunatly this negates the <merge> optimisations.
Navigation Drawer is available in the Support Library of android it uses DrawerLayout inside. The main advantage is improved performance.
They also have different visual effects. SlidingMenu looks like horizontal scroll view. Sliding it in will push the main content out.
Pros :
It comes with cool entrance / exit animations for the menu content.
Depending on what Activity you use it on, it can be placed below the Action Bar or next to it (pushing the Action Bar too)
You can explicitly set the touch mode via a setter: margin or full screen. In full screen mode touching anywhere on the screen will open the menu. In margin, only when you slide from the edge of screen will the menu open.
Cons :
You can only control the shadow of the side menu
Navigation Drawer / Drawer Layout looks like an additional top level view in a frame layout. Sliding it in will mask the main content.
Pros :
If you use v4 support lib then it's already there.
You can control both the side menu shadow and obscure the main
content via setScrimColor e.g when the drawer is opened, a fade-in
alpha layer will appear above the main content. This is good to visually separate the content and the menu especially when both have a same color.
Cons:
It can only be placed below ActionBar
There is no setter for touch mode and by default you can only do margin touch mode. Doing a full screen touch mode (like Youtube) involves a lot of work
I think the best advantage is that It is official Google code, I mean it just works and works excellent.
The main disadvantage is that it is very basic to use, I mean... you cannot put two navigation drawer in the same activity or fragment, you can only use one in left and that's it.
You already said it yourself. Sliding menu is third party. Navigation drawer is official. Both have the same purpose, but third party libraries might implementing it slightly differently, depending on which one you use.