How to add custom action bar with navigation box?

I tried using Custom Action bar as:

bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); bar.setCustomView(R.layout.xyz); 

but the navigation box becomes invisible.

+6
source share
3 answers

I had the same problem, but I found a way to solve the problem. You need to install:

 getActionBar().setCustomView(R.layout.xyz); getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); 

Then the navigation drawer + icon will appear.

If you do not want the icon to be visible, you can place a transparent image (just make a transparent image transparent.png and put it in a drawable folder) instead of the application icon. You can do this by defining a new style for the 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> 
+11
source

For me it worked:

getActionBar().setCustomView(R.layout.xyz); getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);

+1
source

actionBar.setDisplayOptions (ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);

+1
source

All Articles