Android的动作栏没有显示在displayOptions - useLogo [英] Android Action Bar not showing on displayOptions - useLogo
问题描述
我有一个 actionBarStyle
,我已经实现了我的应用程序为我的动作条
。这是下面的XML code:
I have an actionBarStyle
that I have implemented in my app for my ActionBar
. Here is the xml code below:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyActionBarTheme" parent="@android:style/Theme.Holo">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">@style/MyCustomActionBar</item>
</style>
<style name="MyCustomActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@android:color/transparent</item>
<item name="android:backgroundSplit">@android:color/transparent</item>
<item name="android:displayOptions">useLogo</item>
</style>
和这里是我的活动的OnCreate
:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setLogo(R.drawable.ic_logo);
setContentView(R.layout.activity_home);
initializeViews();
manageFragments();
}
现在的问题是,我的动作条
根本不显示,当我从删除 displayOptions
项目我XML。它显示的标题。现在我可以随时删除标题(设置标题字符串只是空白),但我不希望如此,因为它显示了默认的动作条
风格/主题为几秒钟,那么我的自定义主题(我想你知道这一个)。我不知道是什么问题。请帮忙。谢谢...
The Problem is that my ActionBar
doesn't show at all and when I remove the displayOptions
item from My XML. It shows with the title. Now I can always remove the title (set the title string to just blank) but I don't want that as it shows the default ActionBar
style/theme for a few seconds and then my custom theme (I guess you know this one). I don't know what the problem is. Please help. Thanks...
推荐答案
如果您设置了安卓标志
的主题,你不应该需要将其设置在$ C $℃。
If you set the android:logo
in the theme you shouldn't need to set it in code.
我想你可能还需要 showHome
在你的显示选项,例如
I think you may also need showHome
in your display options e.g.
<item name="android:displayOptions">showHome|useLogo</item>
修改
下面是一个例子主题,我用它来隐藏的标志和,该样本是使用显示在操作栏中的标题 ActionBarSherlock
所以你需要调整父样式名称相应地,如果你不使用它。
Below is an example theme I use to hide the logo and display the title in the action bar, this sample is using ActionBarSherlock
so you will need to adjust the parent style names accordingly if you aren't using it.
<style name="AppTheme" parent="style/Theme.Sherlock.Light.DarkActionBar">
<item name="android:windowBackground">@color/background_primary</item>
<item name="android:icon">@drawable/appicon</item>
<!-- For the home as up icon on sub pages -->
<item name="android:homeAsUpIndicator">@drawable/back</item>
<item name="homeAsUpIndicator">@drawable/back</item>
<item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
<item name="actionBarStyle">@style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="android:displayOptions">showTitle</item>
<item name="displayOptions">showTitle</item>
<item name="android:titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
<item name="android:background">@color/actionbar_bg_color</item>
<item name="background">@color/actionbar_bg_color</item>
<item name="android:backgroundStacked">@color/actionbar_bg_color</item>
<item name="backgroundStacked">@color/actionbar_bg_color</item>
这篇关于Android的动作栏没有显示在displayOptions - useLogo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!