Navigation Drawer icon not shown - android

I am using Custom Action bar. For which the code i am using is -
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().setCustomView(R.layout.custom_home_action_bar);
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(
R.color.color_dark_blue)));
but when I use this code to customise my action bar, navigation drawer icon is not shown. When I comment these lines it is perfectly shown but then I cannot customise my action bar.How can i achieve both?
Thanks in advance

I got the solution. I used
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
instead of
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

Related

Add image to left side of action bar ?

I need add a image in between navigation button and drop-down in action-bar.How can I do this?
you need to call setIcon() it will change the icon
getActionBar();
ActionBar actionBar = getActionBar();
actionBar.setIcon(R.drawable.my_icon);
see this for more detail

How to implement drawerlayout with custom action bar?

If i use default actionbar i can set home button to open and close drawerlayout with this code.
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
And it's work well.
But i dont't want default actionbar i want actionbar with customlayout.
When i use custom actionbar i don't know how to implement home button for open and close drawerlayout.
How to implement drawerlayout with custom action bar?
PS. I use custom actionbar because i want set title text to align center of actionbar, set text and text size to it's.
EDIT
thank you every body i can solve it's by use this.
getActionBar().setCustomView(R.layout.actionbar);
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
it's work well but the home button image change from app logo to app icon.
You can create custom Action bar like this ..
// gets actionBar reference ..
actionBar = getSupportActionBar();
// This sets custom layout to action bar
actionBar.setCustomView(R.layout.action_provider);
// this is how... .... you get id of layout defined
iv_d = (ImageView) actionBar.getCustomView().findViewById(R.id.action_menu);
Now just open you drawer on click of this icon using OnClick()
That's it .. you are good to go.

Actionbar Sherlock tabs and navigation list

I'm using sherlockbar. How do I add a ActionBar bar with tabs and a navigation list? As this image from Google Maps
In my code, I can not seem to set two behaviors for ActionBar
ActionBar bar = getSherlockActivity().getSupportActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
the opt navigation (Meus Lugares) are added using the menu onCreateMenu .
The other are Tabs which you add using
bar.AddTab()

How to remove Application icon from Action Bar in Android?

I am using Action bar with Tabs. I want to hide app icon from action bar. I use the below code, but action bar is showing below Tabs. Both are not useful for me.
Any one help me!
actionBar.setDisplayUseLogoEnabled(false);
and
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayUseLogoEnabled(false); should do it.
add
actionBar.setDisplayShowTitleEnabled(false)

Blank title in action bar

Is it possible to remove title bar which I think is ugly and doesn't fit in my application but still use actionbar? After I call
requestWindowFeature(Window.FEATURE_NO_TITLE | Window.FEATURE_ACTION_BAR);
the title bar stays but piece of my view is gone(cant scroll up)
Is it possible to get rid of title bar but still keep actionbar, if I dont request it as window feature getActionBar() returns null everytime..
Following Honeycomb, Action Bar was introduced to provide more functionalities, Well you can hide logo and title from it using this
ActionBar ab = getActionBar();
ab.setDisplayShowTitleEnabled(false);
ab.setDisplayShowHomeEnabled(false);

Categories

Resources