操作栏上没有应用程序图标 [英] No App Icon on ActionBar

查看:30
本文介绍了操作栏上没有应用程序图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有很多关于向 ActionBar 添加图标的问题,但没有一个能解决我的问题.如果您知道此问题的副本,请随时发表评论或关闭此问题.

There are a lot of queries here about adding icons to ActionBar but none solved my problem. If you know a duplicate of this question, feel free to comment or close this question.

我将我的项目迁移到 IntelliJ 并且我之前的 IDE (Eclipse) 没有遇到这个问题.

I migrated my project to IntelliJ and I didn't encounter this problem with my previous IDE (Eclipse).

问题:应用图标未显示在操作栏中.

我认为它应该是默认添加的,这就是为什么我不能通过它的 XML 添加它

I think it's supposed to be added by default that's why I can't add it through its XML

这是它的 XML

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

    <item android:id="@+id/action_settings"
        android:title="@string/action_settings"
        android:orderInCategory="100"
        app:showAsAction="always" />
</menu>

谢谢!

推荐答案

从 AppCompat 版本 21 开始,操作栏遵循 材料设计指南 并使用 工具栏:

As of AppCompat version 21, the Action Bar follows the material design guidelines and uses a Toolbar:

  • 标题和副标题.标题应该是工具栏在导航层次结构中的当前位置以及其中包含的内容的路标.副标题(如果存在)应指示有关当前内容的任何扩展信息.如果应用使用徽标图片,则应强烈考虑省略标题和副标题.
  • A title and subtitle. The title should be a signpost for the Toolbar's current position in the navigation hierarchy and the content contained there. The subtitle, if present should indicate any extended information about the current content. If an app uses a logo image it should strongly consider omitting a title and subtitle.

在现代 Android 用户界面中,开发人员应该更多地依赖于工具栏的视觉上不同的配色方案,而不是他们的应用程序图标.不鼓励在 API 21 及更新版本的设备上使用应用程序图标和标题作为标准布局.

In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.

但是,如果你想要一个应用程序图标,setLogo() 是正确的方法.

However, if you want an application icon, setLogo() is the correct method.

这篇关于操作栏上没有应用程序图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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