I\'m using ActionBar.Tab setCustomView() method with this layout:
To every created tab object just add layoutParams:
..
tab.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
actionBar.addTab(tab);
You have to rely on android:margin
and android:padding
when dealing with actionbarcompat's setCustomView
keeping in mind that it seems like the root element's padding, width, height, and margin, gets ignored.
If you're still having the issue, I found a way to get the whole space : ActionBar Tab with custom View not centered
Just ran into this myself and figured out the solution. You should create a style for the tabview that clears the background and the padding and use it in your theme.
styles.xml:
<style name="Custom.ActionBar.TabView.Empty" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@null</item>
<item name="android:padding">0dp</item>
</style>
themes.xml:
<style name="Theme.Custom" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarTabStyle">@style/Custom.ActionBar.TabView.Empty</item>
<item name="actionBarTabStyle">@style/Custom.ActionBar.TabView.Empty</item>
</style>