As you guys can see, my app's name has been overlapped by Action bar's items. I have only two items in action bar.
Is it possible to show only one item there so that it couldn't overlap the app name and rest of the item/s in overflow menu(the default behavior..)?
Wondering why its not sensing the app name and arranging its items accordingly?
Edit (actionbar.xml):
<item
android:id="#+id/about"
android:title="#string/about"
android:showAsAction="ifRoom|withText"
>
</item>
<item
android:id="#+id/email"
android:title="#string/email"
android:showAsAction="ifRoom|withText">
</item>
Thanks.
Are you using ActionBarSherlock? I believe I had a similar problem until I changed my theme in my androidManifest.xml to be derived from Theme.Sherlock.ForceOverflow
Add to AndroidManifest.xml under application tag
android:theme="#style/Theme.Sherlock.ForceOverflow"
Related
I have a problem, in my app I need to add 2 buttons to the ActionBar, i change the menù file in this way
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/navigation_drawer"
android:icon="#drawable/ic_drawer"
android:title="Drawer"
android:showAsAction="ifRoom" />
<item android:id="#+id/info"
android:icon="#drawable/ic_info_outline_white_24dp"
android:title="info"
android:showAsAction="ifRoom" />
</menu>
but my items are in the overflow button without the image , only the text , how can I do to take off from there and make images appear on ActionBar ? it would be possible to put one on the left and one to the right of the name of the app ?
You can use android:showAsAction="always" to make them always show on the ActionBar.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto" >
<item android:id="#+id/action_chat"
android:icon="#drawable/ico_enter_chat"
android:title="Enter Chat"
compat:showAsAction="always|withText" />
<item android:id="#+id/action_map"
android:icon="#drawable/ico_map"
android:title="Users Map"
compat:showAsAction="always" />
<item android:id="#+id/action_logout"
android:icon="#drawable/ico_log_out"
android:title="Log Out"
compat:showAsAction="always" />
</menu>
Here is my menu XML file, in theory it should display two icons as single icons and first icon with title too.
However, in app it doesn't display title, here is screencap:
So why doesn't it display "title" ?
Source:
http://developer.android.com/guide/topics/ui/actionbar.html#ActionItems
If your menu item supplies both a title and an icon—with the title and icon attributes—then the action item shows only the icon by default.
If you want to display the text title, add "withText" to the showAsAction attribute.
Note: The "withText" value is a hint to the action bar that the text title should appear. The action bar will show the title when possible, but might not if an icon is available and the action bar is constrained for space.
The Android system thought that there is no enough room to display the title of the menu item completely, so it hides the title (although there might be enough room, but Android doesn't think so.) If you turn into landscape or run the app in a tablet, the title will show up.
This declares that the Search action should appear as an action button when room is available in the action bar, but the Settings action should always appear in the overflow. (By default, all actions appear in the overflow, but it's good practice to explicitly declare your design intentions for each action.)
https://developer.android.com/training/basics/actionbar/adding-buttons.html
This worked for me
app:showAsAction="ifRoom|withText"
appcompat_v7 > values > config.xml
<bool name="abc_config_allowActionMenuItemTextWithIcon">false</bool>
change
<bool name="abc_config_allowActionMenuItemTextWithIcon">true</bool>
in my android application i have a few Activities which extends ListActivity. What i want is to have a split ActionBar and or Icons in my ActionBar in those extended Activities.
Currently it doesent work. The Items in ListActivities are just shown in the onCreateOptionsMenu (three dots). I just created a simple layout for a test and modifided my manifest file.
Layout:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="#+id/new_game"
android:title="t1"
android:icon="#drawable/abc_ic_search"
app:showAsAction="ifRoom|withText"/>
<item android:id="#+id/help"
android:title="t2"
android:icon="#drawable/abc_ic_search"
app:showAsAction="ifRoom|withText" />
<item android:id="#+id/help2"
android:title="t2"
android:icon="#drawable/abc_ic_search"
app:showAsAction="ifRoom|withText" />
<item android:id="#+id/help3"
android:icon="#drawable/abc_ic_search"
android:title="t2"
app:showAsAction="ifRoom|withText" />
and in my manifest i tried to add the following to the application tag or just to the ListActivites.
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
In Activities which extend ActionBarActivity everything is running correct. Am i missing something for ListActivities? Does anyone have an idea?
help would be awesome! thanks
try to remove app:showAsAction="ifRoom|withText" or change it to app:showAsAction="always
take a look at this lik
ifRoom : Only place this item in the Action Bar if there is room for it.
withText : Also include the title text (defined by android:title) with the action item. You can include this value along with one of the others as a flag set, by separating them with a pipe |.
never : Never place this item in the Action Bar.
always : Always place this item in the Action Bar. Avoid using this unless it's critical that the item always appear in the action bar. Setting multiple items to always appear as action items can result in them overlapping with other UI in the action bar.
Okay i guess i figured out why it doesent show the splitactionbar. In addition to the meta tag you need to set the attribute uiOptions for a ListActivity + use the android namespace.
android:showAsAction="always"
android:uiOptions="splitActionBarWhenNarrow"
This option is only used for API Level 14 and higher. For Versions lesss than that ive no Idea so far to solve the problem.
I have created a sample android application that just displays some text and i can see that the menu bar at the top of the activity contains name of the application but not the icon of the application. The menu is also very thin just containing application name with a small font. Going through various tutorial i found that we have to select a particular menu style while creating the application to have a menu that contains both application name and icon, but my application just contains application name and the menu is very thin. Is it possible to increase the menu height now and add application icon to it dynamically or by making some changes in menu xml file?
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/app_name" android:icon="#drawable/ic_launcher"
android:title="My App" />
</menu>
If you want to customize the ActionBar, here you are a complete tutorial for it:
How can I implement custom Action Bar with custom buttons in Android?
It's very good an complete for customizing almost everything, so I recommend it to you.
Even tough, I ask you to change your question in order to make more clear the target of it, now you know what you were triying to mean ;)
<menu xmlns:tools="schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context="com.example.sample.getMsgActivity"
xmlns:yourapp="http://schemas.android.com/apk/res-auto">
<!-- Search, should appear as action button -->
<item android:id="#+id/action_write"
android:icon="#drawable/ic_action_refresh"
android:title="#string/action_write"
yourapp:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="#+id/action_read"
android:title="#string/action_read"
yourapp:showAsAction="never" />
REMEMBER: clean, then build. it should work then.
I am trying to get my options to show up in the Title Bar. I'm using ActionBarSherlock and I can figure out how to remove the title in the title bar, but would like to replace the text with 2 options from my options menu.
I'm using this code, EmpubLite as an example for my application, but I can't figure out how Mark (the commonsware guy) got the icons from his options menu in the title bar. My options show up at the bottom in the action bar and this is taking up unnecessary room on the screen. I've been looking through examples here, but can't seem to find out exactly how to get options in the title bar. I'm hoping Mark (or someone) can explain.
would like to replace the text with 2 options from my options menu
Um, unless that happens automatically by removing the title, I suspect that's not possible.
but I can't figure out how Mark (the commonsware guy) got the icons from his options menu in the title bar
Well, you see, that's covered in this delightful little book... :-)
More seriously, android:showAsAction controls whether items should be in the overflow area (never), should be in the action bar (ifRoom), or really really should be in the action bar (always). That being said, always is a hint, not a demand, and the OS may still put your action bar items in the overflow on smaller screen sizes.
You did not state which of the EmPubLite series you are experimenting with. Early on, the items are all set to never:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/help"
android:icon="#android:drawable/ic_menu_help"
android:showAsAction="never"
android:title="#string/help"/>
<item
android:id="#+id/about"
android:icon="#android:drawable/ic_menu_info_details"
android:showAsAction="never"
android:title="#string/about">
</item>
</menu>
By the end of the series, we have some that ideally go into the action bar:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/notes"
android:icon="#android:drawable/ic_menu_edit"
android:showAsAction="ifRoom|withText"
android:title="#string/notes">
</item>
<item
android:id="#+id/update"
android:icon="#android:drawable/ic_menu_save"
android:showAsAction="ifRoom|withText"
android:title="#string/download_update">
</item>
<item
android:id="#+id/settings"
android:icon="#android:drawable/ic_menu_preferences"
android:showAsAction="never"
android:title="#string/settings">
</item>
<item
android:id="#+id/help"
android:icon="#android:drawable/ic_menu_help"
android:showAsAction="never"
android:title="#string/help">
</item>
<item
android:id="#+id/about"
android:icon="#android:drawable/ic_menu_info_details"
android:showAsAction="never"
android:title="#string/about">
</item>
</menu>
My options show up at the bottom in the action bar and this is taking up unnecessary room on the screen.
You have android:uiOptions="splitActionBarWhenNarrow" set in your manifest somewhere, then.