Reputation: 133
So I'm pretty new to android development and I just can't get ANY icon to show up in the actionbar.
I create a new project with minimum sdk API 15 and choose "Holo.Light" in the Theme-Dropdown (XML-Design-View).
So I want it to look like this: https://i.sstatic.net/zfgCq.png
but instead it looks like this: https://i.sstatic.net/4dLik.png
My 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>
I guess I have to change android:theme to Holo.Light somehow? but theres no ressource defined and I cant seem to add any..
my styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"/>
<!-- Customize your theme here. -->
The ic_launcher.png is in the drawables folder.. so what do I have to do to get that damn icon to show up?
(I use my HTC one M8 btw, but it doesnt show up on an emulator either)
thanks!
Upvotes: 5
Views: 13450
Reputation: 11
Another way I solve with this code
ActionBar actionBar = getSupportActionBar();
actionBar.setLogo(R.drawable.ic_launcher);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
Upvotes: 1
Reputation: 2547
To display the icon on ActionBar you have to add :
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);
in onCreate
method.
Upvotes: 16