Last tab in action bar is cropped, goes off screen - android

I'm making an Android app using tabs for navigation.
I have a problem with the rendering of the last tab in the action bar; it goes off screen and is cropped (this happens as soon as the number of tabs is too big too fit in the screeen width as far as I can tell).
I'm using the ActionBar.NAVIGATION_MODE_TABS navigation mode.
I haven't been able to find any questions with the same problem, any ideas on how to prevent this behavior?

I have already answer a question like that one : Tab item width in Action Bar (Android)

Related

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 make the actionbar transparent

i am learning actionbar and created an actionbar with tabs .the following image shows the view
!
requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
ActionBar ab=getActionBar();
ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ab.setBackgroundDrawable(new ColorDrawable(Color.MAGENTA));
ab.addTab(ab.newTab().setText("Popular").setTabListener(this));
ab.addTab(ab.newTab().setText("Latest").setTabListener(this));
ab.addTab(ab.newTab().setText("Nearby").setTabListener(this));
They following are my queries :
the tabs have shifted to a bar below the magenta color bar. is it due to space constraints of mobile.if a wish to add any item to this magenta bar with the tabs below how can add to it and then show the same pattern whether it is mobile or tablet.
i want to make this tabs bar transparent so that i can see the text move behind it.i have tried to set its drawable as per code above but it has only changed of top bar but not the tabs bar.
what is way to have a button on the magenta bar onclicking i have this screen shift to left and show another screen which has some links show up in a way that partly this current screen is also visible.i hope i am able to explain my point.
kindly clarify
Question 1: It's down to device space constraints. The first paragraph in the Android documentation for tabs in the action bar show that if there isn't room it will split the tabs to a separate bar.
http://developer.android.com/guide/topics/ui/actionbar.html#Tabs
Question 2: You need to set the drawable for the background and the stacked background of the action bar to your transparent drawable. (Edit: Links in Ye Lin Aung's comment show how to do that).
Question 3: It sounds like you are looking for a navigation drawer layout arrangement to me. The best place to start on this would be this link:
http://developer.android.com/training/implementing-navigation/nav-drawer.html
Edit: The pattern will work the same for both mobile and tablets (though you may want to have an xml for smaller screens that have a slightly thinner drawer sizes).
The android documentation in the link above states that the drawer width should be set in dp units and that the drawer height matches the parent view. The drawer width should be no more than 320dp so the user can always see a portion of the main content. This should allow most phones to view it in both portrait and landscape and still see some content.

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!

android action bar with tabs below the screen

For my application , I'm planning to have a design as this:
http://img811.imageshack.us/img811/7045/problemel.png
-Design needs to have a title bar which is indeed the action bar in android. To overcome the compatibility issues, I used the sherlock action bar which is said to support older versions that dont have action bars. I havent tested yet for the older devices however.
-As far as I know, for navigation , we could rather use tabbed or dropdown list methods. I want to have constant tabs for every page in my app to stand below the page. This reflects the tabbed action bar, however I want it below not just under the action bar. I don't know how but youtube application somehow has it in the middle of the screen (if it's not a custom view). So how do we have tabs positioned in the bottom of the page?
-Also I want to have another menu, whose items depend on the page it's on. But the apperance will be the same for every page. In the picture on the left this menu has buttons as "Bt 1" ,"Bt 2". I dont want to repeat the same xml for every activity page, but I'm not sure how to achieve it without repeating. If the action bar allowed using both navigation tabs and the drop down list, I could put the items of this menu in the dropdown list just as the picture on the right (onto the gray button). But I guess it does not?!
Therefore I have to repeat the menu xml code in every page or is there another smart way?
Any advice will be appreciated.
This can be achieved not with tabs but by adding items to a linear_layout with a gravity of bottom but it is a bad practice as #D_Steve595 stated and should be avoided in android designs.
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);

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