简体   繁体   English

Android ActionBar菜单图标未出现

[英]Android ActionBar Menu Icons not appearing

Before you Tag as a duplicate question: I've read: 在您标记为重复问题之前:我读过:

Action buttons doesn't show up on Action Bar? 动作按钮没有显示在动作栏上?

Action Bar not showing action view icons 操作栏未显示操作视图图标

and

Android: Icons don't appear in Action Bar Android:操作栏中没有出现图标

But the issue is not resolved. 但是问题没有解决。 My action bar will only hold the menu items in the overflow. 我的操作栏仅将菜单项保留在溢出中。 I cannot get the icons to appear on the action bar itself. 我无法使图标显示在操作栏本身上。

The code for my menu is: 我菜单的代码是:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item android:id="@+id/homeIcon"
    android:title="@string/Home"
    android:icon="@drawable/ic_home_black_24dp"
    android:orderInCategory="1"
    app:showAsAction="always" /></menu>

I have declared the support header files but it hasn't made a difference. 我已经声明了支持头文件,但是并没有改变。 I tried replacing the word 'app' in "app:showAsAction" with my app name as it appears in @strings but it will not accept it because the app name has white space. 我尝试用出现在@strings中的应用名称替换“ app:showAsAction”中的“应用”一词,但由于应用名称带有空格,因此它不接受。

it is called my App instead of myApp. 它称为“我的应用”而不是“我的应用”。

Is there that the reason why i can't get any icons in my actionBar, if yes is there a way to resolve it.. without recreating my app? 那是为什么我无法在actionBar中获得任何图标的原因,如果可以的话,有没有一种方法可以解决它..而无需重新创建我的应用程序? i tried changing the name in @strings and that didn't resolve the issue, so it could just as easily be something else. 我尝试更改@strings中的名称,但无法解决问题,因此也很可能是其他问题。

Thanks in advance community! 在此先感谢社区!

Probably you are not using AppCompat (or not using it in this particular situation) then android:showAsAction . 可能您没有使用AppCompat(或者在这种特殊情况下没有使用它),然后是android:showAsAction Yes, Android Studio will complain and recommend to use app:showAsAction but it works. 是的,Android Studio会抱怨并建议使用app:showAsAction但它可以工作。

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

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