Tabs go to top if i set customView of ActionBar on Android - android

I add tabs and viewpager to my project.
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Everything is perfect until i set custom view of actionBar:
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
....
actionBar.setCustomView(vv,layoutParams);
Perfect: ActionBar itself at the top and tabs are below the actionBar.
When i set the custom view, tabs change place and goes to top and actionBar goes to below of tabs.
What am i doing wrong? I want the actionbar stay always at the top of the screen.

You can vote for this bug on Android code:
https://code.google.com/p/android/issues/detail?id=36191
There are some tricks to avoid this that you can read here: https://github.com/JakeWharton/ActionBarSherlock/issues/327
But the official Google answer is
This is a working as intended UX decision.
(Roman Nurik).

Related

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)

Changing android actionbar background not working

ActionBar actionBar = getSupportActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#330000ff")));
actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#550000ff")));
I'm trying to change my actionbar and the tab backgrounds, using the code above, the actionbar background changes perfectly but the tab backgrounds doesn't change at all, I'd like to know if this is due to the fact that I use supportActionBar or not, if anyone has a solution, Thanks!
it's easier to use it via xml.
have you tried out the next links:
https://developer.android.com/training/basics/actionbar/styling.html#CustomTabs
http://jgilfelt.github.io/android-actionbarstylegenerator/
?

ActionBarSherlock with Tabs

I am trying to implement ActionBarSherlock with three tabs in the way that the tabs are placed in the same line as HomeButton. See the picture below:
I created the ActionBarSherlock and added the three tabs but they did not appear on the screen. What did I miss?
Here is my code:
//ActionBarSherlock settings
ActionBar actionBar=getSupportActionBar();
Resources res=getResources();
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(res.getDrawable(R.drawable.logo));
actionBar.setSplitBackgroundDrawable(res.getDrawable(R.drawable.separator));
actionBar.setBackgroundDrawable(res.getDrawable(R.drawable.navbar));
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
//Tabs
actionBar.addTab(actionBar.newTab().setText("apps").setIcon(R.drawable.ico_apps_normal).setTabListener(this).setTag("apps tab"),true);
actionBar.addTab(actionBar.newTab().setIcon(R.drawable.ico_add_normal).setTabListener(this).setTag("add tab"));
actionBar.addTab(actionBar.newTab().setIcon(R.drawable.ico_news_normal).setTabListener(this).setTag("news tab"));
Try adding
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
before you start adding your tabs. It seems like you haven't set your navigation mode.
I've also answered a similar question regarding Actionbars and navigaton tabs here

Adding headers and footer in actionbar tabs

Hi everyone I am working currently a view which need to have a view above the tabs of the actionbar or more like below the action bar itself, and a fixed footer between the tabs.
But I have not find a way to make this behaviour other than adding the footer in each fragment and the view that I want below the tabs.
Is there a way to put headers(above) and footer(below) tabs using the actionbar?
PD. I am using Sherlock actionbar
Something inbetween the Actionbar and the Actionbar tabs? AFAIK it's not possible. ABS is only used in pre HC versions. On ICS+ the default ActionBar gets used. Therefore even if you can customize the ABS Actionbar you most likely can't override the default Actionbar on ICS+.

Categories

Resources