Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logo are not displayed in Actionbar, using AppCompat

I don't know where I missed something, but I can't set my logo in my actionbar. My AndroidManifest.xml:

<application      android:icon="@drawable/application_icon"      android:label="@string/icon_name"     android:logo="@drawable/actionbar_logo"     android:theme="@style/PolarTheme"> 

And also I set my logo in my activity tag in the manifest:

<activity      android:name=".Main"     android:theme="@style/PolarThemeLogo"     android:logo="@drawable/actionbar_logo"     android:windowSoftInputMode="adjustPan"> </activity> 

This is in my themes.xml:

<style      name="PolarThemeLogo" parent="Theme.AppCompat.Light.DarkActionBar">       <item name="colorPrimary">@color/mainColor500</item>     <item name="colorPrimaryDark">@color/mainColor700</item>     <item name="colorAccent">@color/accentColorA200</item>      <item name="actionBarStyle">@style/MyActionBarLogo</item>     <item name="android:windowContentOverlay">@null</item> </style> 

My styles.xml:

<style name="MyActionBarLogo" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">     <item name="background">@color/mainColor500</item>     <item name="displayOptions">useLogo</item> </style> 

In my Main.java:

public class Main extends ActionBarActivity {  @SuppressLint("NewApi") @Override public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.main);         ActionBar actionBar = getSupportActionBar();     actionBar.setTitle("");     actionBar.setDisplayUseLogoEnabled(true); 

Any ideas?

UPDATE - SOLVED

I removed all the android:logo attributes from my AndroidManifest.xml and I modified my MyActionBarLogo style like this:

<style name="MyActionBarLogo" parent="@style/Widget.AppCompat.Light.ActionBar">     <item name="background">@color/mainColor500</item>     <item name="logo">@drawable/actionbar_logo</item>     <item name="displayOptions">useLogo|showHome</item> </style> 

Now the actionbar is displaying my logo. :)

like image 452
zkminusck Avatar asked Oct 20 '14 18:10

zkminusck


2 Answers

I use the following code to show the logo, hope it would be helpful.

getSupportActionBar().setDisplayUseLogoEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setIcon(R.drawable.logo); 
like image 167
alijandro Avatar answered Oct 16 '22 09:10

alijandro


I removed all the android:logo attributes from my AndroidManifest.xml and I modified my MyActionBarLogo style like this:

<style name="MyActionBarLogo" parent="@style/Widget.AppCompat.Light.ActionBar">     <item name="background">@color/mainColor500</item>     <item name="logo">@drawable/actionbar_logo</item>     <item name="displayOptions">useLogo|showHome</item>     </style> 

Now the actionbar is displaying my logo. :)

like image 41
zkminusck Avatar answered Oct 16 '22 09:10

zkminusck