Reputation: 143
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.
Upvotes: 9
Views: 12669
Reputation: 2350
This works well for me:
//show the icon
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);
Upvotes: 0
Reputation: 807
Try like this
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME |
ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP |
ActionBar.DISPLAY_USE_LOGO);
getSupportActionBar().setIcon(R.drawable.search_icon);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Upvotes: 0
Reputation: 531
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);
Upvotes: 12
Reputation: 349
The actionbar uses the android:logo attribute from manifest file. Then use setDisplayUseLogoEnabled() to set it in the ActionBar
Upvotes: 2