I'm scratching my head to find the correct way to implement a dynamic sliding/expanding menu (not sure the name is correct though) in android.
An image showing what i'm trying to achieve :
(source: teneuesdigital.com)
In the image you can see the ipad version behind has an expandable menu. when you click in an item in the root menu, it automatically expands to the right, displaying the sub-menu items. This is repeatable for each sub-menu : each time a new sub-menu appears to the right.
Now, I'm designing this app for both tablets and phones. So the idea is that on tablets the menu would expand to the right, filling the available screen space, BUT on phones, the currently displayed menu ( ListView) should be replaced by the clicked Sub-Menu's List.
I started playing with fragments and ListFragment without success...
I guess fragments are the way to go (but I could be wrong) since the layout is completely different depending on the screen size.
For the Tablet version :
My idea would be to first display the root menu as a first ListFragment, then when an item is clicked, have a new Fragment created and sliding to the right of the first. Would that work ? How would you do it?
For the phone (mdpi) version :
The currently displayed menu fragment is always replaced with the sub-menu fragment ... I guess that's easy enough with fragment transactions.
Now another question I'm asking myself is how do I implement this in the same activity ?
Do I need to detect screen resolution to manage the different FragmentTransaction types depending if we have to expand the menu or replace the currently visible one?
How can this be done in an efficient way?
Many thanks for all your ideas and comments.
As an idea, you can use ListViews with Visibility:gone in A Realtive layout, Or Expandable ListView. I implemented the first one & it is the simplest.
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.
I'm not sure a ViewPager is the way to go, but it might.
My goal is to create an App with 3 screens.
A main screen and 2 other screens the are reachable by swiping left and right from the main screen.
i would like to have the screens as Fragments.
I have used a ViewPager, but I would like to get rid of the TabBar, and just stay with the swipe.
I managed to get rid of the Tabs, but the bar remains empty. I want it to be hidden.
Is that possible?
Is there a better way to do it ?
If this question was already answered, I have failed to find it and will appreciate redirection as well.
Thanks a lot,
Giora.
In your AnsroidStudio layout screen, go to the "Design" tab. Click on the theme option and select a theme with "NoActionBar.FullScreen" AFAIK ViewPager does not have any TabBar by default.
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
I'm trying to implement an application with a specific view. It needs to have a horizontal bar at the top that contains the app icon, and other buttons and spinners. These items must be static and should appear on every page of the app.
Below that horizontal bar will be a Tabbed component, with the tabs being horizontal at the bottom of the page. I can also implement the desired behavior with the tabs on top of the Tabbed component. Each tab will obviously change the fragment being displayed within the tab's frame.
I am working on an implementation that uses the ActionBar and the menu options. However, I can't get the menu options (my buttons and spinners) to appear above the tabs. And I'm not sure if menu options is the right approach. Any ideas?
Silly me! the answer was right there. I simply had to turn the title bar back on (only with no title) and the menu options would appear right into that title bar.
keep in mind that this feature is heavily dependent on the version of android and model of device that you have.
Older phones have a menu button which will bring up the same menu, as do some modern phones (like the galaxy SIII), so, be sure to test this everywhere so you know what the end-user will actually experience.
I want to create a app with a menu at the bottom of the screen. This menu should be visible any time the app is started.
Im working with fragments, so the menu is one fragment.
So I have only one Activity as controller which loads different fragments above the menu fragment.
Because I want to create clean code, i dont know how to solve the problem that the Activity class is too big.
In other words, i want to create different controller within the same activity. How to do that?
Is there another approach to solve this issue?
You should be using the split action bar This allows you to put the Actions and overflow menu on the bottom of the screen. I believe you can use Action Bar Sherlock for backwards compatibility to older versions of Android. See their site for detail.
Another possibility is to look into using fragments with the ViewPager . Here is a library that works with compatability as well ViewPageIndicator . Here is a blog post , like I indicated in my comment I got this working with the tabs showing at the bottom and the pages above.