因此,我对android开发来说还很陌生,但是我无法在操作栏中显示任何图标。
我使用最低sdk API 15创建了一个新项目,并在Theme-Dropdown(XML-Design-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?但没有定义资源,我似乎无法添加任何资源。
我的styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"/>
<!-- Customize your theme here. -->
ic_launcher.png在drawables文件夹中..那么我该怎么做才能显示该死的图标?
(我使用HTC一部M8 btw,但它也未显示在模拟器上)
谢谢!
要在ActionBar上显示图标,您必须添加:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);
在onCreate
方法上。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句