菜单图标不动作栏中显示 [英] menu icon not displaying on action bar

查看:95
本文介绍了菜单图标不动作栏中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android Studio 0.5.8

您好,

出于某种原因,该图标永远不会显示在动作条,我已经使用了ifRoom组合| withText,但仍然没有显示。我也曾尝试旋转景观。我使用genymotion 4.4.2

For some reason the icon never displays on the ActionBar, I have used a combination of ifRoom|withText but still doesn't display. I have also tried rotating in Landscape. I am using genymotion 4.4.2

<?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:title="@string/new_crime"
        android:id="@+id/menu_item_new_crime"
        android:icon="@drawable/ic_action_new"
        app:showAsAction="always"/>
</menu>

我膨胀菜单中的片段:

I am inflating the menu in a fragment:

 @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.fragment_crime_list, menu);
    }

下面是截图:

Here is a screenshot:

我曾在纵向和横向模式的硬件nexus5,但没有图标。

I have tried hardware nexus5 in portrait and landscape mode, but no icon.

我也尝试过使用以下,但也不能工作:

I have also tried using the following, but didn't work either:

android:icon="@android:drawable/ic_menu_add"

非常感谢您的任何建议,

Many thanks for any suggestions,

推荐答案

我也碰到过这个问题,一旦自己。试试这个:

I have come across this issue once myself. Try this:

<?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:title="@string/new_crime"
        android:id="@+id/menu_item_new_crime"
        android:icon="@drawable/ic_action_new"
        android:showAsAction="always"
        app:showAsAction="always"/>
</menu>

我不知道为什么,就必须同时拥有,但固定它,我出于某种原因。

I don't know why it would be necessary to have both, but that fixed it for me for some reason.

这篇关于菜单图标不动作栏中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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