Im using actionbarsherlock tab navigation and they work fine.
The only problem im having is that when going in landscape mode the tabs dont fill the whole width of the screen and are small unlike in portrait.
I been looking at styling the tabs but i cannot find the right setting to make the tabs wider.
What do I need so the tabs can fill the width on the screen in landscape
It seems that the only way to do this is using a custom view. Check this out:
Set menu items centered and full-width with ActionBarSherlock
Related
I'm implementing android tabs in the actionbar but seems when displaying the screen on tablet i have a weird issue.
The tabs look like this:
Does anyone knows a fix or a workaround so the tabs can fill the width of the actionbar?
This simple setting works for me:
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
How do i make a tab bar look like this:
Yes, this is the tab of contact app of android 4.2.2 on samsung galaxy s3.
This is what I have so far:
As you can see, the height of the tabs is a bit low so the indicator override the text. So I need to increase the tab bar height.
The problem is I can't increase the height of the tabs further. Because of new android policy that limit tabs height ( it is explained here: Change Actionbar height on Android JellyBean).
Then how did google do that? Is there any tutorial to make a custom tab bar, or is there a trick to by pass limit of tab bar height?
Thank you very much for reading my quesion.
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.
I have one tough question. I am now playing with design of the Android application and I have the problem with way how the tabs are displaying from some width of display. I use ActionBarSherlock library and ViewPager for tabs.
The problem is that I use yellow color for ActionBar, black for tabs and again yellow for tab indicators, but when I look at the application on wider screen or in landscape mode (I guess approximately from width 400dp) I can't see the indicators, because tabs are hiden in action bar and indicator has exactly the same color. Is there som way how to change color of tab indicators from some display width?
I have tried to do it by making of layout-sw400dp/layout.xml, new 9patche's and new styles, but I can't make it work this way and I think now that it is impossible to do it this way. Do you have any idea how to do this?
Thank you very much in advance.
UPDATE
I have solved it in the following way. I have created folders drawable-w400dp and drawable-land (for ancient phones). Only phones where it will probably be displayed in the wrog way are black berry like androids.
Have you tried using the Action bar style generator. I used this and my tabs have highlights in both orientations http://jgilfelt.github.com/android-actionbarstylegenerator/ it generates 9patches and XML for you
I am using a action bar. I have menu items on that. I have set the property on it as
android:showAsAction="ifRoom|withText"
So it's working in Potrait and landscape really well. On one page I have Tabs, it's not recognizing tabs and overwriting the tabs. What I would like to do is, in Potarit just show tabs and all menu in drop down. In Landscape show tabs and as many menu items possible on action bar.
Thanks,
Have a res/menu/options.xml and a res/values-land/options.xml to distinguish the cases. Or, if the rule really is not portrait vs. landscape but a minimum screen width, use res/menu/options.xml and res/menu-wNNNdp/options.xml, where NNN is the minimum width in dp for when you want to use some other approach for your menu.