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>
And here is my Activity OnCreate
:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setLogo(R.drawable.ic_logo);
setContentView(R.layout.activity_home);
initializeViews();
manageFragments();
}
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...
This works from 4.2 api version.
In your ActionBar style add this…
Complete Example , adding a new Theme for your complete App.
If you set the
android:logo
in the theme you shouldn't need to set it in code.I think you may also need
showHome
in your display options e.g.EDIT
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.if you want use code to implement this effect, you can call below code from a Fragment.
and you need to specify the logo attribute of the activity in the AndroidManifest.xml, for example,