标志不显示在动作条,利用AppCompat [英] Logo are not displayed in Actionbar, using AppCompat
问题描述
我不知道我错过了什么,但我不能把我的标志在我的动作条。 我的AndroidManifest.xml:
I don't know where I miss 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 at my activity tag in manifest:
<activity
android:name=".Main"
android:theme="@style/PolarThemeLogo"
android:logo="@drawable/actionbar_logo"
android:windowSoftInputMode="adjustPan">
</activity>
这是我的themes.xml:
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>
我的styles.xml:
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>
在我的Main.java:
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?
更新 - 解决
我删除了所有的机器人:从我的AndroidManifest.xml标志
属性和我修改了这样的MyActionBarLogo风格:
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. :)
推荐答案
我删除了所有的Android:从我的AndroidManifest.xml中的标志属性和我修改了这样的MyActionBarLogo风格:
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. :)
这篇关于标志不显示在动作条,利用AppCompat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!