所以我是 android 开发的新手,我无法在操作栏中显示任何图标。
我创建了一个最低 sdk API 15 的新项目,并在主题下拉列表(XML 设计 View )中选择“Holo.Light”。
所以我希望它看起来像这样: http://i.stack.imgur.com/zfgCq.png
但它看起来像这样: http://i.imgur.com/Lmxutct.png
我的 AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
我想我必须以某种方式将 android:theme 更改为 Holo.Light?但是没有定义资源,我似乎无法添加任何资源..
我的样式.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"/>
<!-- Customize your theme here. -->
ic_launcher.png 在 drawables 文件夹中..所以我需要做什么才能让那个该死的图标显示出来?
(顺便说一句,我用的是我的 HTC one M8,但它也没有出现在模拟器上)
谢谢!
最佳答案
要在 ActionBar 上显示图标,您必须添加:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);
在 onCreate
方法中。
关于android - 应用程序图标不显示在操作栏中 (Android Studio 1.0.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27680560/