简体   繁体   English

appcompat v7 23-带有app:showAsAction =“ withText | always”的菜单项不显示标题

[英]appcompat v7 23 - Menu Item with app:showAsAction=“withText|always” doesn't display title

I have a menu item, with icon and text. 我有一个菜单项,带有图标和文字。 I am using Appcompat v7 library. 我正在使用Appcompat v7库。 The menu item is not displaying text, even when showAsAction is set to withText|always or vice-versa. 即使将showAsAction始终设置为withText |,反之亦然,菜单项也不显示文本。

menu.xml menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_next"
        android:icon="@drawable/ic_action_registration_next"
        android:orderInCategory="0"
        android:title="Next"
        app:showAsAction="always" />
</menu>

I have tried these combinations for showAsAction. 我已经为showAsAction尝试了这些组合。

always|withText
withText|always
ifRoom|withText

The toolbar only shows the icon, but not the title. 工具栏仅显示图标,但不显示标题。 How can i show both title and icon? 如何显示标题和图标? Please look at the image below: 请看下面的图片:

在此处输入图片说明

Let me know if you need anything else. 需要帮助请叫我。

Action bar/toolbar implementations consider withText to be a request, not a command. 动作栏/工具栏实现将withText视为请求,而不是命令。 They will decide whether to show the text on whether or not there is sufficient room for it. 他们将决定是否显示文本以显示是否有足够的空间。 In this case, appcompat-v7 apparently thinks that there is not enough room. 在这种情况下, appcompat-v7显然认为空间不足。 If you try rotating this device to landscape, or testing on a tablet, you should see the title show up, if you have withText as part of your app:showAsAction attribute. 如果您尝试将此设备旋转到横向,或在平板电脑上进行测试,并且您的app:showAsAction属性中包含withText ,则应该会显示标题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM