适合工具栏标题 [英] Fit Toolbar title

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

问题描述

我的应用程序存在以下问题,尤其是操作栏:

和ID(用红色矩形表示),但是由于审美原因不能更改操作栏的大小或其中包含的图标,因此我想在用户使用时显示带有整数和ID的文本按我突出显示的部分.

当前,我正在设置这样的文本(delivery var和idDelivery是字符串):

    ActionBar ab = getActionBar();
    ab.setTitle(delivery);
    ab.setSubtitle("ID:" + idDelivery);

有什么想法吗?

解决方案

MenuItemshowAsAction属性更改为ifRoom:

<item app:showAsAction="ifRoom"
        .../>

来自文档:

仅在有足够空间放置此项目时,才将其放置在应用程序栏中.如果没有所有标记为"ifRoom" 的项目的空间,则将具有最低orderInCategory值的项目显示为操作,其余项目显示在溢出菜单中.

因此,Toolbar的标题将具有更高的优先级,并且MenuItem仅在有足够空间容纳它们时才显示,否则将留在溢出图标弹出菜单下显示./p>

I have the following issue with my app, specifically with the Action Bar:

and the ID (indicated with the red rectangle) but since the size of the Action Bar nor the icons contained in cannot be changed due to esthetic reasons, I would like to display a text with the whole number and ID when the users press in the section I've highlighted.

Currently, I'm setting the text like this(delivery var and idDelivery are Strings):

    ActionBar ab = getActionBar();
    ab.setTitle(delivery);
    ab.setSubtitle("ID:" + idDelivery);

Any ideas?

解决方案

Change MenuItems showAsAction attribute to ifRoom:

<item app:showAsAction="ifRoom"
        .../>

From 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.

Thus, the title of your Toolbar would be given higher priority, and MenuItems would be displayed only when there is enough room for them, otherwise they would be left to be displayed under overflow icon popup menu.

这篇关于适合工具栏标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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