从上下文操作栏中删除标题 [英] Remove Title from Contextual Action Bar

查看:151
本文介绍了从上下文操作栏中删除标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除上下文操作栏中为标题分配的视图。

I want to remove the view that is allocated for the title in a contextual action bar.

请注意,我不想设置标题;我希望视图完全消失。这是为了提供更多的空间,以便可以将操作显示在菜单栏上,而不是放到溢出菜单中。

Please note that I do not want to set the title; I want the View entirely gone. This is to allow more room so that actions can be displayed on the menu bar rather than being dropped into the overflow menu.

还请注意,我不想设置 android:showAsAction = always 。我希望Android决定图标的空间。我只是想通过删除保留给标题的空白区域来更多空间

Also note that I do not want to set android:showAsAction="always". I want Android to decide how much space there is for the icons. I just want there to be more space by removing the blank area that is reserved for a title.

更新

我尝试过的事情:


  • ActionMode。 setCustomView(null)

  • ActionMode.setTitleOptionalHint(true)

  • ActionMode.setTitle()

  • ActionMode.setCustomView(null)
  • ActionMode.setTitleOptionalHint(true)
  • ActionMode.setTitle("").

不幸的是,这些都不起作用。

Unfortunately, none of these have worked.

更新2

事实证明,按照我的尝试无法达到我想要的结果。删除标题不会为更多图标留出空间; Android会根据设备屏幕尺寸设置硬限制。如果要在菜单中添加更多图标,请参见@adneal提供的答案。

It turns out my desired results are impossible to achieve in the way I was attempting. Removing the title will not allow room for more icons; Android sets a hard limit based upon the device screen size. If you are wanting to add more icons to the menu, see the answer provided by @adneal.

如果您确实有标题(如下所示)并想删除然后,您可以调用@CommonsWare在接受的答案中提供的 ActionMode.setTitle()

If you actually have a title (as shown below) and want to remove it, then you can call ActionMode.setTitle(""), as provided by @CommonsWare in the accepted answer.

推荐答案

尝试在 ActionMode 上调用 setCustomView(null)

如果这不起作用,请在 ActionMode setTitleOptionalHint(true) >。

If that does not work, try setTitleOptionalHint(true) on the ActionMode.

如果这不起作用,请在上尝试 setTitle()动作模式

If that does not work, try setTitle("") on the ActionMode.

这篇关于从上下文操作栏中删除标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆