Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Action bar Sherlock tabs width inconsistency?

Tabs in Android 2.2 occupying full width.

enter image description here

enter image description here

Tabs in Android 4.2 nexus 7, tabs not occupying full width. Both having same code. using actionBarsherlock
e.g.

final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// add tabs
Tab tab1 = actionBar.newTab().setText("TabTitle1")
 .setTabListener(new MyTabListener(null));
actionBar.addTab(tab1);

What am I missing? Should this be fixed in theme! I just want the tabs to occupy full available width

like image 386
sat Avatar asked May 01 '13 15:05

sat


1 Answers

This is not a bug for two reasons:

  1. ActionBarSherlock is a backport of the Android 4.0 action bar UI and API to previous versions of Android. Any changes in the behavior of the action bar after Android 4.0 will not be backported. This behavior changed in Android 4.2.
  2. You are comparing two vastly different sizes of device. If you grab a 1280x720 XHDPI phone running Android 4.2 you'll see that two tabs span the width of the device when in portrait. Grab a 1280x768 XHDPI phone on 4.2 (e.g. Nexus 4) and you'll see the two tabs do not span the full width because the size is becoming too large to accomodate at full width.
like image 99
Jake Wharton Avatar answered Oct 24 '22 00:10

Jake Wharton