1

In my application, in one of the activities I have 2 tabs displaying different content, the problem is that when I load it in my normal screen device & large screen device it's just fine, tabs are below the actionbar, but when I load it in xlarge screen device, the tabs are moved to the top of the actionbar, here's how I handle my actionbar:

    ActionBar ab = getActionBar();
    ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    ab.setCustomView(R.layout.action_bar);
    ab.setDisplayShowHomeEnabled(false);
    ab.setDisplayShowTitleEnabled(false);

I also used :

    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

but the result was the same in xlarge screen devices. any idea why is this happening and how to fix it??

PS: I know ActionBar is deprecated in android 5.0 and replacing the actionbar is not an option for me at the moment. Later I'll have to replace it but at the moment I have to fix this.

Thanks in advance.

arash moeen
  • 4,533
  • 9
  • 40
  • 85

2 Answers2

1

The tabs show on top when you hide the Home item. This is known issue, but Google marked it as "Working as intended". You can find some ways to fix this in this bug report. Also, please take a look at this question.

Community
  • 1
  • 1
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
1

try in below order declare ActionBar , its works for me i hope its works for you

 actionBar = getActionBar();
 actionBar.setDisplayShowHomeEnabled(true);
 actionBar.setDisplayHomeAsUpEnabled(false);
 actionBar.setHomeButtonEnabled(false); 

 View homeIcon = findViewById(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ?  android.R.id.home : R.id.abs__home);
    ((View) homeIcon.getParent()).setVisibility(View.GONE);
    ((View) homeIcon).setVisibility(View.GONE);

 actionBar.setDisplayShowTitleEnabled(false);

 actionBar.setCustomView(R.layout.action_bar);
 actionBar.setDisplayShowCustomEnabled(true);
Lokesh
  • 3,247
  • 2
  • 33
  • 62
  • Thanks man I'll check it later, sadly I have to wait until Monday, but thanks anyway. – arash moeen Nov 06 '14 at 11:42
  • It fixed the problem totally and now it's working as I wanted to, I'm gonna accept this as an answer. thanks man... alooott. but please elaborate about that abs_home and what I should put there... – arash moeen Nov 08 '14 at 08:05