适合工具栏标题
Fit Toolbar title
我的应用程序存在以下问题,特别是操作栏:
和 ID(用红色矩形表示)但由于操作栏的大小和其中包含的图标由于美观原因无法更改,我想显示一个包含完整数字和 ID 的文本用户按下我突出显示的部分。
目前,我正在这样设置文本(传递变量和 idDelivery 是字符串):
ActionBar ab = getActionBar();
ab.setTitle(delivery);
ab.setSubtitle("ID:" + idDelivery);
有什么想法吗?
将 MenuItem
s showAsAction
属性更改为 ifRoom
:
<item app:showAsAction="ifRoom"
.../>
来自docs:
Only place this item in the app bar if there is room for it. If there is not room for all the items marked "ifRoom", the items with the lowest orderInCategory values are displayed as actions, and the remaining items are displayed in the overflow menu.
因此,您的 Toolbar
的标题将被赋予更高的优先级,并且 MenuItem
只有在有足够的空间时才会显示它们,否则它们将显示在下面溢出图标弹出菜单。
我的应用程序存在以下问题,特别是操作栏:
和 ID(用红色矩形表示)但由于操作栏的大小和其中包含的图标由于美观原因无法更改,我想显示一个包含完整数字和 ID 的文本用户按下我突出显示的部分。
目前,我正在这样设置文本(传递变量和 idDelivery 是字符串):
ActionBar ab = getActionBar();
ab.setTitle(delivery);
ab.setSubtitle("ID:" + idDelivery);
有什么想法吗?
将 MenuItem
s showAsAction
属性更改为 ifRoom
:
<item app:showAsAction="ifRoom"
.../>
来自docs:
Only place this item in the app bar if there is room for it. If there is not room for all the items marked "ifRoom", the items with the lowest orderInCategory values are displayed as actions, and the remaining items are displayed in the overflow menu.
因此,您的 Toolbar
的标题将被赋予更高的优先级,并且 MenuItem
只有在有足够的空间时才会显示它们,否则它们将显示在下面溢出图标弹出菜单。