I have two fragments. One displays my general content (fragment A). The other, fragment B, is displayed over the top of fragment A. I would like for my action bar to have a z-order in the middle of these two layouts. That is, the fragment B would be displayed in front of the action bar.
My question is, is it possible to display a view in front of the action bar?
It is possible.
After all, applications can already display in full screen and not in full screen with the action bar whenever they like. You can set that programmatically yourself in Java.
import android.app.ActionBar;
...
// Show action bar
ActionBar actionBar = getActionBar();
actionBar.show();
...
// Hide action bar
ActionBar actionBar = getActionBar();
actionBar.hide();
Just make sure there is a good reason to alternate this common UI convention on Android.
Related
I would like to ask whether there is a way to put a TextView between the title in the action bar and the tabs in the action bar. It has to be on it's own separate line.
The other way is to implement tabs with the TabHost and put the view above it, but I will have a hard time making tabs look like the tabs in the ActionBar, because by design they have to be like them.
I was developing an app for Android 2.3 where the menu sat nicely at the low right together with the back and home buttons.
I've been using
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
to fully utilize the screen area.
Now, i'm adapting it to SDK>10, and here the menu sits at the top right in the action bar.
Using the above code line hides the action bar, which means I can't see the menu any more.
I could hide the action bar of course by using
ActionBar actionBar = getActionBar();
actionBar.hide();
Where should I put my
ActionBar actionBar = getActionBar();
actionBar.show();
if I'd like to show the action bar by touching the edges of the screen, just like how the software buttons show up?
Regards
/M
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.
Im using action bar sherlock and in landscape mode all of my tabs show, but in portrait only one shows.
How can I show all tabs so the user can slide along them? They dont have to be on screen at the same time, I just dont want a pop up menu.
A bit old question and you may already figured out how to fix it, but here's a solution for people struggling (like I was) with the same issue. In fact, the documentation says the following:
Note: In some cases, the Android system will show your action bar tabs as a drop-down list in order to ensure the best fit in the action bar.
To avoid the drop-down list when your tab items don't fit the screen, add your tabs to ActionBar and set navigation mode after adding the items.
ActionBar bar = getSupportActionBar();
//bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Don't set navigation mode yet, if you do then portrait mode will revert to list mode if tab items don't fit the screen
bar.setLogo(logo);
bar.setHomeButtonEnabled(false);
bar.setDisplayHomeAsUpEnabled(true);
bar.setDisplayShowTitleEnabled(false);
// Add lots of tab items
for (int i = 0; i < channels.length; i++) {
ActionBar.Tab tab = bar.newTab();
String[] s = channels[i].split(":");
tab.setText(s[0]);
tab.setTag(s[1]);
tab.setTabListener(this);
bar.addTab(tab);
}
// Set navigation mode now, that will show all tabs in portrait mode instead of drop-down regardless the screen size
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
That's it :)
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);