简体   繁体   中英

App icon not showing in the Title Bar for Android Studio

Hello Stackoverflow Community,

I recently began to study android development, and I am almost certain I encountered a bug. I hope someone with knowledge in this matter can confirm this and provide a quick workaround.

Here is the link to the same question and more discussion (the OP in the link is not me): http://forums.udacity.com/questions/100235173/app-icon-not-showing-in-the-title-bar

Basically, what the OP did was replace the default android app icon with a custom one. I am pretty sure he or she did it correctly because everyone else, including myself, is having the same issue. Yet, assuming that the OP did it correctly, there is no app icon located in the title bar (see the first image).

If we were to run the "Hello World!" program without modifying the default app icon, the result would still be the same. That is, there is going to be no app icon located in the title bar by default.

Some users suggest that this is due to the theme... Another user also suggests that this only occurs when the project is created using "Blank Activity with Fragment" (note that everyone is using "Blank Activity with Fragment" and not any other activities).

If anyone could give some sound advice onto this matter, it would be much appreciated!

Thanks!

Some users suggest that this is due to the theme

Those users are correct. The screenshot would appear to be from an app running on Android 5.0 that is using a theme based on Theme.Material .

This is intended behavior by Google, and therefore does not represent a bug.

I got it working on Android 5.0, just adding these lines into the onCreate method, inside MainActivity:

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.drawable.ic_launcher);
getSupportActionBar().setDisplayUseLogoEnabled(true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM