Tab Width in Action Bar (Android)

I use 12 tabs in Activity, in the action bar (the goal is API 17, tested on Galaxy Nexus 4.2.2).

As expected, I get a horizontal scroll list under my action bar. In the screenshot below, you can see that the last tab (B on the right) is noticeably smaller than the other tabs (the "E" tab is not taken into account in the "E" tab, it can be scrolled because there are four more tabs on the left).

From the blue glow it is clear that there is nothing more to scroll. I use Theme.Holo.Light.DarkActionbar by default, without any custom view.

Why is this last tab smaller than the other? And how can I make sure that he becomes the same as the others?

One tab is smaller than the others

+3
source share
1 answer

Indeed, I ran into the same problem, and the only work I found was to disable tab separators. There seems to be an error in the native action bar that does not care about the size of the delimiters when measuring the tab bar container.

<style name="actionBarTabBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.TabBar"> <item name="android:showDividers">none</item> </style> 

(Here I use actionbarsherlock, but this is not the source of the problem, you can extend your style from the parent = "@android: style / Widget.Holo.ActionBar.TabBar")

And apply it in your subject:

 <item name="android:actionBarTabBarStyle">@style/actionBarTabBarStyle</item> 

If you absolutely need an actionBar separator, one simple solution would be to add it directly to the background of the tab (left or right).

+3
source

Source: https://habr.com/ru/post/1492857/


All Articles