Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action bar app icon missing with Android 5

Tags:

android

Just rebuilt my app using the Android 5 SDK and associated appcompat.

Seems to work fine but my app icon is no longer showing in top left hand corner. The icon to open nav drawer is there but no icon.

Any way to fix this?

like image 802
JohnMoll Avatar asked Oct 23 '14 10:10

JohnMoll


2 Answers

Use the code below in onCreate:

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.drawable.ic_launcher);
getSupportActionBar().setDisplayUseLogoEnabled(true);
like image 67
Alexey Avatar answered Oct 16 '22 08:10

Alexey


I too noticed that the default projects created by Android Studio were missing the icon in the action bar. Here's how I fixed it.

Disclaimer: This solution will result in in the Material theme being dropped in favor of the older JellyBean/Kitkat styles.

First, change themes setting in styles.xml from this:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

To this:

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">

Now change all your Activities to inherit from android.app.Activity instead of android.support.v7.app.ActionBarActivity. That is:

Change this:

import android.support.v7.app.ActionBarActivity;

public class MainActivity extends ActivityBarActivity {

To this:

import android.app.Activity;

public class MainActivity extends Activity {

The end of result of doing this is an app that has the Holo theme more commonly seen on Jelly Bean and Kitkat.

like image 37
selbie Avatar answered Oct 16 '22 08:10

selbie