I'm developing an application in which I'd like the tab bar to appear and disappear based on the direction the user is scrolling. I use bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); to show the tab bar and bar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); to hide the tabbar. The only problem is that when I hide the tab, it leaves behind a blank gray space (see second figure) instead of having the listview fill up the space. I also tried overlaying the actionbar by using requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); but it didn't seem to help. I can provide any additional code needed. Any ideas? Thanks in advance!
Try removing all tabs and setting the navigation mode to standart:
actionBar.removeAllTabs();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
Related
I am following this tutorial. The tutorial basically helps to create a sliding tab menu by using the AppCompat library. It basically creates a custom toolbar using the tabs and then replaces the standard ActionBar with this toolbar.
It works perfectly, but I do not wish to show the title. I only want the tabs at the top of the screen to be my main navigation. On my activity I have set
getSupportActionBar().setTitle(null);
but this only makes the text for the title blank. Space (padding?) is still reserved for the title. How do I remove it?
The picture below shows the problem visually.
I'm using ViewPager to display tabs in Android, but in a circumstance, I want to display a fragment on top of the pager/tabs, but NOT on top of the ActionBar. If I hide the action bar, they both disappear. If I don't do it, I can't find a way to get rid of pager's tab bar (or whatever it's called). Here is a visual representation of what I'm trying to achieve:
How can I hide that bar without hiding the action bar?
I think you can do it by setting a new navigation mode.
Use setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD) to hide them
Use setNavigationMode(ActionBar.NAVIGATION_MODE_TABS) to show them again
Edit:
Please note that the setNavigationMode methods are deprecated in Android Lollipop.
Reference
Use this to get rid of tabs in actionbar
setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD)
My UI uses ABS with tabs (ActionBar.NAVIGATION_MODE_TABS) and a bunch of fragment layouts being loaded for each tab.
There is one tab where I need to hide the ActionBar (to reclaim some screen space) for the UI but calling getSupportActionBar().hide(); would nuke the tabs along with the ActionBar.
I was wondering if there is was anyway at all where I could hide the actionbar without affecting the tabs?
EDIT: Actually, come to think of it, the Actionbar doesn't do anything except showing the app branding/icon. So I wouldn't mind hiding the ActionBar altogether and just showing the tabs.
This is called a 'collapsed action bar'. It will be automatically hidden if you don't display the title and the home icon:
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
If you want to have both tabs and actions, you can use a split action bar and have the actions (menus) at the bottom.
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);
I am trying to build the ActionBar Tab with tabs bottom. Can some one please throw light on how to have the Android3+ version's ActionBar tabs at bottom?
Can some one please throw light on how to have the Android3+ version's ActionBar tabs at bottom?
AFAIK, tabs are always at the top, even with a split action bar.
AFAIK, the ActionBar is always at the top.
You might be thinking about split action bar though. This is used for phones that have smaller screens so they can take some additional items.