Android - invisible ActionBar with back button - android

I know how to implment ActionBar with back button. But I want to make ActionBar invisible or with no background, I want to have only visible back button arrow. Is it possible?

With a little of search you will find the response. Any way you can try this :
ActionBar actionBar = getSupportActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000")));
If you want to have your tab background below your ActionBar add this too :
actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000")));

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

hide up button and show icon as home in action bar

actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeButtonEnabled(true);
i have this code to hide title and up button in my code and show only the icon but my problem is when i click on the icon it doesnt work anymore meaning it does not bring me to home activity anymore but when i set actionBar.setDisplayHomeAsUpEnabled(false); to true it works ok any idea on how to make this work the way i want it to work

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.

How to hide ActionBar, but keep the Tab navigation buttons?

I'm new in creating Android apps, and I would like to hide the Title, App Icon, and the whole top area of the ActionBar, but keep the Tabs Navigations below it. Is it possible?
Here is an explanation picture about what I want exactly:
This will show only tabs:
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
// Set your tabs below

Removing an icon from the Actionbar

I want a custom ActionBar with Tabs that has a graphic background (displaying just one image) and 3 tabs.
I can't remove the icon of the actionbar.I've been through tens of stackoverflow questions about how to remove the icon and title, but nothing worked.
I have a minSdk=14, ViewPager, ActionBar compat7, ActionBarActivity. Would any of these hinder it?
This is the code I have. Some declarations are excessive, I've been trying everything I could.
The best I got is an actionbar with no title, but the icon never goes away.
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowHomeEnabled(false); // this hides the icon well but doesn't
// work if you use actionbar tabs (viewpager)
solution below
Thanks
Have you tried for actionBar.setDisplayShowHomeEnabled(false)
The solution is this:
((View)findViewById(android.R.id.home).getParent()).setVisibility(View.GONE);
as seen on: https://github.com/JakeWharton/ActionBarSherlock/issues/327#issuecomment-10593286
Using actionBar.setDisplayShowHomeEnabled(false) hides the icon, but your actionbar ends up being below the viewpager tabs (if you're using any)

Categories

Resources