I've got a nice ActionBarSherlock setup with three tabs. The left and right tabs are set up just as icons, and the middle one is a custom layout.
In portrait mode, this looks great. The tabs are nicely centered in the action bar, and all is well with the world:
However, in landscape mode, the tabs are flushed to the left:
Here's how I set up my tabs:
Tab leftTab = mActionBar.newTab().setIcon(R.drawable.ic_action_login_black).setTabListener(tabListener);
mActionBar.addTab(leftTab);
Tab centerTab = mActionBar.newTab().setCustomView(R.layout.actionbar_logo).setTabListener(tabListener);
centerView = (RelativeLayout) centerTab.getCustomView();
mActionBar.addTab(centerTab, true);
Tab rightTab = mActionBar.newTab().setIcon(R.drawable.ic_action_video_black).setTabListener(tabListener);
mActionBar.addTab(rightTab);
And here's my XML for that custom view in the center tab:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="48dp"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" >
<ImageView
android:id="@+id/my_logo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/my_logo" />
</RelativeLayout>
If it matters, I'm using minSdkVersion=15.
I'd like the tabs to be centered, just as they are in portrait mode. Is that possible?