I tried using Custom Action bar as:
bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
bar.setCustomView(R.layout.xyz);
but navigation drawer becomes invisible.
I had the same problem, but I found a way to go around the problem. You need to set:
getActionBar().setCustomView(R.layout.xyz);
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
Then, it will show navigation drawer + icon.
If you don't want the icon to be visible, you can put a transparent image (just make transparent image transparent.png
and put in drawable folder) instead of app icon. You can do that by defining new style for Action Bar (styles.xml
):
<style name="Theme.MyAppTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/Theme.MyAppTheme.ActionBar</item>
</style>
<style name="Theme.MyAppTheme.ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:icon">@drawable/transparent</item>
</style>
For me worked:
getActionBar().setCustomView(R.layout.xyz);
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With