I am trying to remove the title from my action bar and reclaim the space it would otherwise consume for the use of menu items.
I have tried using a custom theme but so far nothing has worked. I have tried changing the text size to 0sp, changing the color to transparent, and setting visibility to gone.
I have also tried this :
ActionBar actionbar = getActionBar();
actionbar.setDisplayShowTitleEnabled(false);
I am targeting sdk 15+ and using the standard Android action bar (i.e. not Sherlock).
Thanks for any suggestions.
Here's what I'm talking about (the area bordered in red I want back):
Did you check out the ActionBar documentation yet? There's a method, setDisplayShowTitleEnabled(boolean) that does what you need.
Simply get a reference to your ActionBar, and call that with false:
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
Related
I am trying to give a choice to the user to change the actionbar color at runtime but I can able to change the whole theme at runtime except the actionbar. Can anyone help me to change the actionbar color at runtime in android.
You can try this (Hope you are suing Actionbar not Toolbar)
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable("COLOR"));
Check this link for more
I'm using an actionbar with NAVIGATION_MODE_TABS set. What do you call that rectangle that appears at the bottom of the tab that is selected? And how do I customize it?
I don't know how it is called, maybe tab highlight.
Anyway, customize it with the Android Action Bar Style Generator.
Is it possible to remove title bar which I think is ugly and doesn't fit in my application but still use actionbar? After I call
requestWindowFeature(Window.FEATURE_NO_TITLE | Window.FEATURE_ACTION_BAR);
the title bar stays but piece of my view is gone(cant scroll up)
Is it possible to get rid of title bar but still keep actionbar, if I dont request it as window feature getActionBar() returns null everytime..
Following Honeycomb, Action Bar was introduced to provide more functionalities, Well you can hide logo and title from it using this
ActionBar ab = getActionBar();
ab.setDisplayShowTitleEnabled(false);
ab.setDisplayShowHomeEnabled(false);
I am trying to add and action bar to my app, and customize it.
i used onCreateOptionMenu() and Inflaters to add to my code.
but i don't know how to customize background and remove that package name which appears next to the logo so i can give more "Room" to my items to be displayed correctly.
can anybody help please?
Thank you in advance.
I would suggest to create a custom action bar in layout folder and use it with below code:
ActionBar actionBar = getActionBar(); //Applications action bar isntance
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.my_action_bar);
If you use this, you can directly use action bar view's content and do whatever you want.
I want to create Action Bar like this
I saw in Dev guide that Action bar icon should be in specific size
is it possible ?
and also is it possible to add item in action bar with no clickable indication ?
i understand your concerns about the action bar icons' size, i had the same, until i discovered this http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html
it's a tool which re-size icons for your whatever you want to add to your app, it also provides few ready cliparts that are ready for use, you just have to click download .zip and you'll get it.
Have fun developing your action bar.
//use your custom xml view to show your customize icons
View actionBarView = getLayoutInflater().inflate(R.layout.action_bar_custom_view, null);
actionBar.setCustomView(actionBarView);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
Yes can do it. But it is good to stick to the icon sizes recommended. As working along with UI guidelines go a long way.
To make your left icon no-clickable, try setHomeButtonEnabled. Since this api is available only on ICS and above and in previous versions icon is enabled by default. So you might have an active icon which does nothing. (Well you can live with this limitation as there are not many 3.x devices)
Custom view is your view so its your wish to make it clickable or not. To add custom view,
mActionBar = getActionBar();
mActionBar.setDisplayShowTitleEnabled(false); // if you dont want title
mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM);
mActionBar.setCustomView(R.layout.action_bar_custom_view);