【发布时间】:2015-03-09 11:30:51
【问题描述】:
我正在尝试为整个应用程序向我的 ActionBar 添加一个图标。
我在清单中的 Appication 标签中引用了 CustomActionBarTheme。
我的操作栏变成蓝色,但没有图标。
有人知道为什么吗?
谢谢
[重复] show icon in actionbar/toolbar with AppCompat-v7 21
<application
android:name=".NfcScannerApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/CustomActionBarTheme"
android:debuggable = "true" >
.
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">@color/cf_blue</item>
<item name="android:icon">@drawable/ic_launcher</item>
<!-- Support library compatibility -->
<item name="background">@color/cf_blue</item>
<item name="icon">@drawable/ic_launcher</item>
</style>
</resources>
【问题讨论】:
-
@CommonsWare 再次感谢马克,辛苦了。如果您愿意,请创建一个答案。
-
我建议您选择您喜欢的任何一个并将此问题标记为重复。
-
@CommonsWare 当使用自定义操作栏时,它强制使用两个
- 标签,一个用于当前版本,另一个用于支持库。像
- @style/MyActionBar
和- @style/MyActionBar
。 - 标签,一个用于当前版本,另一个用于支持库。像
-
这能回答你的问题吗? how to set app icon in action bar in android
标签: android android-theme