Action Bar remove title and reclaim space

倖福魔咒の 提交于 2019-12-14 03:47:27

问题


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):


回答1:


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);


来源:https://stackoverflow.com/questions/12327395/action-bar-remove-title-and-reclaim-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!