Show both logo and app name in android action bar
I have set these two lines of code to display the logo and application name in the action bar, but only the application name appears, for example in the screenshot:
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(R.drawable.icon);
Do I need other code to show both? I added this to the manifest, but the same result:
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:logo="@drawable/icon"
I am working on a tabbed activity with an action bar.
Could you help me? Thanks you
+3
source to share
4 answers
Try this in your .xml style:
<!-- 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 if this creates problems with high api levels, but works for me on API 10.
+2
source to share