I have have some problems with devices that have the action bar. When running on a phone I want to go fullscreen with no title bar and no status bar. On tablets I want to show the action bar but still no title bar. Minsdk is 7! The method setTheme doesn't work when you toggle fullscreen so I can't have two themes. Is there a way to show the action bar in fullscreen mode? The support library doesn't support the Action bar.
The only reason I want to do this in the first place is cause they for no good reason at all broke the backward compability by moving the menu key to the action bar. The easy solution for this according to the docs is to add android:showAsAction="ifRoom" to the menu items. But that does absolutly nothing.
I've also tested numerous solutions I found on google that supposedly toggles fullscreen. None of them work on any of my devices so please do not point to something you've read if you haven't used it yourself.
EDIT: I Solved this. The problem seems to be that you have to specify a Holo theme to get the action bar back. Otherwise it won't show. I added this in my main Activity.
#Override
public void setTheme(int resid) {
if(isTablet(this))
{
super.setTheme(android.R.style.Theme_Holo);
return;
}
super.setTheme(resid);
}
On tablets I want to show the action bar but still no title bar
The action bar replaces the title bar. There is no concept of an activity having an action bar and a title bar.
Is there a way to show the action bar in fullscreen mode?
AFAIK, no, by definition.
The support library doesn't support the Action bar.
ActionBarSherlock provides a backport of the action bar for API Level 7 and higher.
The easy solution for this according to the docs is to add android:showAsAction="ifRoom" to the menu items. But that does absolutly nothing.
It certainly "does nothing" if you have no action bar. If you want a fullscreen experience, then you will need to roll your own menu replacement. IMHO, most fullscreen apps did this already (e.g., a game going with a game-styled "menu").
Related
What are the different bars available in android and where are they located? Pics to support each type would be highly appreciated and helpful for beginners.
The status bar is where the clock, battery icon, notification icons, and the like reside. Most of the time, it is at the top of the screen. This is provided by the system; the app does not directly manipulate the contents of this bar.
The action bar (sometimes referred to as the app bar), if it exists for an activity, will be at the top of the activity's content area, typically directly underneath the status bar. Activities control whether there is an action bar and, if so, what it looks and works like.
The navigation or system bar is where the HOME, BACK, etc. buttons are. This is usually on the opposite side of the screen from the status bar, and therefore usually is at the bottom of the screen. This is provided by the system; the app does not directly manipulate the contents of this bar.
Avoid confusion and call them:
status bar
app bar (action bar is also ok)
navigation bar
Synonyms
action bar, app bar, and title bar all refer to the same thing. A Toolbar is a certain implementation of this bar.
One of the purposes of the status bar is to show notifications. Therefor some call it the notification bar.
The navigation bar is sometimes called the system bar, but the latter name should be avoided. It's too easy to mistakenly think that the system bar contains system information like battery level and network connection, while that's actually the job of the status bar to show these things. The term navigation bar is much clearer. I've also seen it getting called home bar.
Note that iOS also has a navigation bar where it serves a slightly different purpose compared to android - the purpose overlaps with android's navigation and action bars. Moreover, the navigation bar in iOS is typically (always?) located at the top, just below the status bar. See Navigation Bars on developer.apple.com.
References
Android bars at material.io (status bar, app bar, navigation bar)
Add the app bar at developer.android.com (app bar, action bar, Toolbar)
#android:style/Theme.NoTitleBar is a theme without an app bar. It was later called action bar in the code, e.g. in #android:style/Theme.Holo.NoActionBar. (title bar, action bar)
Navigation Bars in iOS on developer.apple.com (different purpose of navigation bar in iOS)
Recently I switched to the v7 Support Library to integrate Material Design elements.
Since then, my contextual action mode is displayed on top of my action bar instead of replacing it (like in another activity of my app).
actionMode on top of actionBar
actionMode overlaying actionBar
I can't figure out why this is happening, because the code for starting and preparing the ActionMode are nearly the same in both activities. I always start them with startActionMode(actionModeCallback); and then inflate the menu.
If you need code samples, feel free to ask. Any help would be appreciated.
Solved it myself: I didn't use the ActionMode version from the support library.
I am new to android.
How can i create option menu with out images like in the attached image? Do i need to use action bar or normal onCreateOptionMenu will do?
If you've developed your application for Android 3.0 (API level 11)
and higher, items from the options menu are available in the action
bar. By default, the system places all items in the action overflow,
which the user can reveal with the action overflow icon on the right
side of the action bar (or by pressing the device Menu button, if
available). To enable quick access to important actions, you can
promote a few items to appear in the action bar by adding
android:showAsAction="ifRoom" to the corresponding elements.
You can refer this doc for more detail.
I would like to override (add more buttons that would take me to several activities/fragments) to the system Navigation Bar on a tablet (according to this android ui-overview it is a "Combined bar" (for tablets)
Is there a way to do this?
I couldn't find a Navigation class in the android.app package, like ActionBar.
If adding buttons to the combined/navigation bar is not possible, I think there are several options, but I'd like to explore this first:
- use the action bar on top instead
- add a bottom bar above the navigation bar (not really fine, since it would be on top of the combined bar), like they are showing here:
Action Bar
Thanks a lot,
Cristian
Is there a way to do this?
No. The only thing you can add to the system bar are Notifications, which are not meant for this sort of navigation.
If adding buttons to the combined/navigation bar is not possible, I think there are several options, but I'd like to explore this first: - use the action bar on top instead - add a bottom bar above the navigation bar (not really fine, since it would be on top of the combined bar), like they are showing here: Action Bar
If you are referring to the section titled "Layout Considerations for Split Action Bars", that is referred to as a "split action bar", and can be enabled on an <activity> via android:uiOptions="splitActionBarWhenNarrow". However, that will only take effect for -small/-normal screens in portrait orientation. Your buttons will automatically be placed in the action bar at the top of the screen in other circumstances.
Is it possible to use fragment tabs on action bar with the Theme.Holo.NoActionBar theme?
I mean... I already use this theme on my layouts but apparently it is overriden since the fragments have to show up in the action bar?
What I wanted to achieve is to actually get rid of the Title and App Icon over the fragment tabs. Something similar to the Google Music app.
Is this possible?
What I wanted to achieve is to actually get rid of the Title and App Icon over the fragment tabs. Something similar to the Google Music app.
Try calling setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false) on your ActionBar, and leave the theme alone.
You can style the action bar based on your needs. I'm quite certain you can also remove the app icon and title from there. Using a NoActionbar theme by default and then recreating the action bar on your own kinda defeats the purpose of the action bar. I suggest you use a theme with action bar and then style the bar according to your needs. This page has a decent implementation.