Reputation: 1067
i have set these two lines of code to display both logo and app name in action bar, but only app name appears, like in the screenshot:
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(R.drawable.icon);
Do i need other code to show both? I have added this in manifest but same result:
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:logo="@drawable/icon"
I'm working on a Tabbed activity with action bar.
Can you help me? Thank you
Upvotes: 12
Views: 31833
Reputation: 407
Add these 3 lines in the onCreate(Bundle) method of your Activity class:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.mipmap.ic_launcher4);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Upvotes: 8
Reputation: 1897
Try this one in your style.xml:
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:icon">@drawable/logo</item>
<item name="logo">@drawable/logo</item>
<item name="displayOptions">useLogo|showHome|showTitle</item>
</style>
Don't know whether this makes problems with high api levels but worked for me on API 10.
Upvotes: 4
Reputation: 1067
Solved adding
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.drawable.icona);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Using logo in actionbar is disabled by default in Android 5.0 Lollipop.
Upvotes: 30
Reputation: 6078
Did you run you app in emulator or real device? I think on the Design page in the fragment does not show the icon of the app when using the layout of API L or 21.(as show below)
But when you change to API 19 or inflate the fragment into tap, it shows.(as show below)
Upvotes: 0