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. :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…