ActionBar Behavior - android

I know there are lots of question regarding Action bar. And may be my question does not require code sample, but this is purely coding stuff.
How do android take decision that in action bar it need to show TABS or List. My question is strictly on android 4.0 and above, whether smart phone or tablet.
Is there some way we can find out that device will be showing Spinner or tabs in action bar.
My question arised when i was deploying my app to Google nexus and Samsung Tab2. In tab I was getting action bar as List in portrait mode and as tab in landscape mode. While i observed opposite in Google Nexus. NOTE This happens when I set my Navigation mode as Tab actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
My question is simple and straight, How Android decide to show List or Tab in action bar.??
and how Developer can check whether List mode will shown or Tab will be shown in action bar?

What I can assume and find that android by itself check for the compact mode and show spinner and tabs accordingly. Not a satisfactory answer but I don't have any thing else to think and find.Any answer with better explanation is acceptable and welcome.
if actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); is set post 4.0 android will check whether enough space is available to show tabs or not. If its not then it transfers tabs to spinner(As drop down).

Related

Using Option menu for non-physical buttons devices

I am developing an application that must hide title bar to increase screen spaces and for design issues. on non-physical buttons devices like nexus-4 and for Android > 3.0, I can't switch to use Action bar because the title bar is hidden, and in the same times these devices hasn't physical buttons to use standard menu.
My Question: How can I solve this problem
Thanks
How can I solve this problem
Modify your UI to either:
Add back the action bar, or
Add something else on your screen, such as a button, to display something else on the screen that will serve as your "menu". You can see this approach used by many games.

Android: Tabbed actionbar in portrait mode

I am unsure what to search for this so all links are appreciated.
When I change the orientation of my device to portrait mode all the tabs are going below the action bar, not on it, even though there is plenty of room (I am using 2 tabs while testing on a Nexus 10). Will the tabs always appear below the action bar in portrait mode or is there a way around this?
What I want to happen:
(source: android.com)
What is happening: NOTE: this is the behavior I am getting even when there is PLENTY of room to display the tabs in the action bar:
(source: android.com)
Thanks in advance!
Will the tabs always appear below the action bar in portrait mode
On small/normal screens, yes. Action bar tabs will go where the action bar implementation wants to put them... which includes them not being tabs at all in some cases, but a drop-down list instead.

How to avoid stacked actionbar when including small tabs

My problem is quite simple, however not sure if there is a clean/easy fix for this. I have an action bar with one tab. In some devices (motorola xoom) the tab is in the action bar, however in some other devices (Nexus 7, Samsung Galaxy 10 tablet), the stacked action bar shows up with the tab on it.
You can see from the picture below that the tab's text is small enough to for the tab to fit in the main action bar instead of spawning the stacked one... I am using a regular action bar, but I've read through the internet that this also happens in Sherlock.
Is there any way to fix this without having to recur to a customView? I wouldn't really want to change all my implementation (tab listeners, etc), just to do this. Thanks in advance!

Design on Android 4.0 (Tab layout)

I'm not sure what direction to take with a Tabbed layout.
I am targeting sdk 15, min sdk 11. Are tabs better left in the action bar or in the "body". I am not designing for tablets with this app (yet), but it seems tablets have tabs in the Action bar and smaller screens do not.
One of the main reasons why I ask is because Google does have some info on tabs here:
http://developer.android.com/design/building-blocks/tabs.html
But I can't seem to find it in their new "Develop" section. So I don't know if this has been deprecated? There used to be a good example on Tab layouts.
You can still use them. They are not deprecated. In the post android 3.0 versions the tabs have been placed in the action bar on tablets. on phones they are below the action bar in portrait and again in the action bar in landscape. it's is considered a good practice to follow those standards as android developer suggests. Now i haven't used the new implementations but rather a compatibility library called ActionBarSherlock. it is actually pretty good and its almost exactly the same in terms of usage as the regular tabs. you can find some good samples on how to implement what you need in there.
Also i am pretty sure you can find all the samples in your android sdk folder under samples/android-14 for example.
I always felt that its easier to browse through them from there as opposed to developer.android.
Hope this helps you.
"If you use navigation tabs in your action bar, once the action items are separated on a narrow screen, the navigation tabs may be able to fit into the main action bar rather than be separated into the "stacked action bar." Specifically, if you've disabled the action bar icon and title (with setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false)), then the navigation tabs collapse into the main action bar."
http://developer.android.com/guide/topics/ui/actionbar.html
This is in fact part of the new design pattern.
If the tabs can fit into the main action bar, let them.
Usually if you're in portrait mode they wouldn't (except for the case stated in the above quote), but when you switch to landscape mode (or if you're on a tablet) they would easily fit.
Everything you find on the developer's site is recommended and is considered good practice. Further, the "design" and "develop" sections go hand in hand... the separation is not meant to imply that "only developers should look at 'develop'" or vice versa. You should treat each as equally important when writing your app.
So yes, it is recommended to implement your tabs with the action bar (as seen in FragmentTabs.java in the API Demos), and it is certainly not deprecated.

Is there an "overflow" view for the Android 3.0+ ActionBar?

I have a number of tabs on the ActionBar and I want to find a way to handle those when the tablet is put into portrait mode. Currently, if you have more than 3-4 and any showing menu items, any more tabs will be cut off and unavailable. I'm wondering if there's a way to have those overflow into a "more" tab automatically. Or, if there's a way to have physical tabs and a drop down list for extra options as the last "tab". Has anyone encountered this scenario yet?
I would do one of the following if I were developing the app that required a use case with a high count of tabs:
Override onConfigurationChanged to detect when in portrait mode and hide the text on the tabs leaving only the icon. Using themes you can also adjust the padding of the tab contents.
Override onConfigurationChanged to detect when in portrait mode and switch the navigation be list-based. This will provide you with more room for action items while still showing the current "tab" that the user is on.
Implement a custom navigation view which responds to portrait in whatever manner you would like (e.g., scrolling horizontally, presenting only the selected tab with text, showing only the selected tab with an overflow-style button for the additional ones).
From http://developer.android.com/sdk/android-4.0.html#ActionBar
The ActionBar has been updated to support several new behaviors. Most importantly, the system gracefully manages the action bar’s size and configuration when running on smaller screens in order to provide an optimal user experience on all screen sizes. For example, when the screen is narrow (such as when a handset is in portrait orientation), the action bar’s navigation tabs appear in a “stacked bar," which appears directly below the main action bar.
Yay!

Categories

Resources