Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to show App logo in action bar

The theme of my application is Light. Can I display app icon in action bar without changing app style from Theme.Light to Theme.Holo.Light.

style.xml

<style name="AppBaseTheme" parent="android:Theme.Light">

AndroidManifest.xml

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:logo="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

The styles of "EditText" and etc object more beautiful with Theme.Light, that why I don't want to change it. It is possible or I should write style for each object and change theme of application.

like image 439
Anamnisis Avatar asked Oct 23 '13 11:10

Anamnisis


2 Answers

This works for me with Theme.Light

android.support.v7.app.ActionBar menu = getSupportActionBar();
menu.setDisplayShowHomeEnabled(true);
menu.setLogo(R.drawable.ic_launcher);
menu.setDisplayUseLogoEnabled(true);
like image 172
Jim109 Avatar answered Sep 27 '22 19:09

Jim109


The actionbar uses the android:logo attribute from manifest file. Then use setDisplayUseLogoEnabled() to set it in the ActionBar

like image 31
Red Devil Avatar answered Sep 27 '22 17:09

Red Devil