应用程序图标未显示在操作栏上 [英] The application icon does not show on action bar

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

问题描述

我按照说明构建了一个新的 android 项目,除了操作栏的问题外,我得到了一个可运行的项目.问题是应用程序图标没有显示在操作栏上的应用程序标题旁边.我使用以下配置创建了项目:

I followed up the instructions of building a new android project and I got a runnable one except a problem with action bar. The problem is that the application icon is not showed beside the application title on action bar. I created the project with the configuration below:

  • 最低要求的 SDK:API 8:Android 2.2(Froyo)

  • Minimum required SDK:API 8: Android 2.2(Froyo)

目标 SDK:API 21:Android 4.X(L 预览版)

Target SDK:API 21:Android 4.X(L preview)

编译方式:API 21:Android 4.X(L 预览版)

Compile With:API 21:Android 4.X(L preview)

Theme:Holo Light with Dark Action Bar(Eclipse 设置相应的appcompat 主题)

Theme:Holo Light with Dark Action Bar(Eclipse set the corresponding appcompat theme)

Android 支持库 21.0.1

Android Support Library 21.0.1

Android SDK 构建工具 21.1.1

Android SDK Build-tools 21.1.1

因为我的最小sdk是api 8,它不支持操作栏,所以项目包含一个appcompat_v7库来允许操作栏功能.如果我将最小 sdk 设置为 api 14(android 4.0) 或更高版本,则该项目不包含 appcompat_v7 库,并且应用程序图标也显示成功.但是我需要我的应用程序来支持低至 api 8 的旧 android 操作系统.那么我应该怎么做才能解决这个问题?非常感谢大家的关注.

Because my minimum sdk is api 8 which does not support action bar, so the project includes a appcompat_v7 library to allow the action bar feature. If I set the minimum sdk to api 14(android 4.0) or higher, then the project does not include appcompat_v7 library and application icon is showed successfully also. But I need my app to support older android os as low as api 8. So what should I do to fix this problem? Really appreciate you guys attention.

P.S:我在 windows、mac、eclipse、android studio 上完成了上面的任务并得到了相同的结果.

P.S: I went through the task above on windows ,mac, eclipse , android studio and got the same result.

推荐答案

您使用的是 AppCompat 21+ 版本,正常.

You are using the AppCompat version 21+ and it is normal.

操作栏遵循材料设计指南并使用工具栏.您可以在此处阅读:

The Action Bar follows the material design guidelines and uses a Toolbar. As you can read here:

使用应用程序图标加标题作为标准布局是不鼓励在 API 21 和更新版本的设备上使用.

The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.

如果你想要一个应用程序图标(但我不鼓励它),你可以使用方法 setLogo().

If you would like an application icon (but I discourage it), you can use the method setLogo().

像这样:

ActionBar actionBar = getSupportActionBar();
actionBar.setLogo(R.drawable.my_logo);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);

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

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