Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Icon doesnt show up in Actionbar (Android Studio 1.0.1)

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: http://i.stack.imgur.com/zfgCq.png

but instead it looks like this: http://i.imgur.com/Lmxutct.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!

like image 917
Tim Avatar asked Dec 28 '14 21:12

Tim


1 Answers

To display the icon on ActionBar you have to add :

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);

in onCreate method.

like image 161
JoaoBiriba Avatar answered Sep 30 '22 15:09

JoaoBiriba