android - 应用程序图标不显示在操作栏中 (Android Studio 1.0.1)

标签 android xml icons themes

所以我是 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/

相关文章:

android - 形状可绘制尺寸不起作用

java - JAXB - 使用 XML 字符串字段编码 java 对象

android - ViewPagerIndicator 选项卡 : Icons above Text

c# - TreeView 加减图标变大

android - 与 onCreateOptionsMenu 方法不同的行为

android - Google Play Services maps 6.5 如何手动触发 map 工具栏

python - 使用 lxml 提取文本

android - 如何更改 Android 中 Button 中使用的 Material Design 图标的颜色

android - RecyclerView 多 View 类型

java - 如何使用java为XML中的节点生成Xpath?