1

I have an action bar with a custom layout that seems to be interfering with how the tabs should layout. I think the problem is that since I'm using a custom view for the action bar when I try to add tabs it wants to put them "in" the action bar instead of below the action bar because of the custom layout. I want the tabs to be below like the would be if I used a regular menu in the action bar.

 LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.menu_default, null);

    ActionBar actionBar = getActionBar();

    actionBar.setCustomView(v);

    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    Tab t =  actionBar.newTab();
    t.setText("tab1");
    t.setTabListener(new TabListener() {

        @Override
        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }
    });

    actionBar.addTab(t);

    Tab t2 =  actionBar.newTab();
    t2.setText("tab2");
    t2.setTabListener(new TabListener() {

        @Override
        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }
    });

    actionBar.addTab(t2);
Brian
  • 4,328
  • 13
  • 58
  • 103
  • 1
    http://stackoverflow.com/questions/19240646/tabs-coming-above-action-bar-when-inflating-custom-layout Hear has a solution form your answer – user3373252 Mar 03 '14 at 02:16

1 Answers1

0

Action bar tabs go where the action bar wants to put them. That may be "in" the action bar or below it, depending on screen size and orientation. You do not have control over the matter.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491