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.
Related
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)
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);
Is there any way, how to set that the Navigation Tabs will be displayed below Action-bar every-time? On my phone is the view like I want it to be - tabs below Action-bar - but on tablet are the tabs inside the Action-bar.
Is there any way how to accomplish that?
You can not force tabs to be below the action bar. You can, however, roll-your-own with a ViewPager and PagerTabStrip. See the post below:
Force stacked tabs
Also, the Android Developers docs have some info:
http://developer.android.com/training/implementing-navigation/lateral.html#PagerTitleStrip
I have Actionbar Sherlock and SlidingMenu set up in my project. I want the menu to slide in under the actionbar, so I set:
setSlidingActionBarEnabled(false);
Though, when I have the action bar Navigation Mode set up with tabs:
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
They stick with the action bar instead of sliding away. That causes the issue of being able to switch tabs and the view pager switching while the menu stays open. Along with it not being the aesthetic I am going for.
Is it possible for the tabs to slide away from the action bar with the menu? Or would it just be more practical to set up a custom implementation with radio buttons?
It's not possible to have the tabs slide when you are using NAVIGATION_MODE_TABS.
The alternative is to use the ViewPagerIndicator library and the TabPageIndicator mode from that. That way the tabs are a part of the activity layout, and will slide. The downside is that the tabs won't get embedded in the action bar on larger devices or when a device is in landscape.
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);