标签项宽度操作栏(安卓) [英] Tab item width in Action Bar (Android)

查看:186
本文介绍了标签项宽度操作栏(安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是12片的一个活动,在操作栏的(目标为17 API,对Galaxy Nexus的4.2.2测试)的。

I'm using 12 tabs in an Activity, in the Action Bar (target is API 17, tested on Galaxy Nexus 4.2.2).

正如预期的那样,我得到在我的操作栏选项卡的horizo​​ntall滚动列表。在下面的截图中,你可以看到,最后一个选项卡(B,右)是noticably小于其他标签的(不走E选项卡上考虑,它可以滚动,因为有4在左边的详细选项卡)的。

As expected, I get a horizontall scrolling list of tabs under my action bar. In the screenshot below, you can see that the last tab (B, on the right) is noticably smaller than the other tabs (don't take the "E" tab into account, it can be scrolled as there are 4 more tabs on the left).

您可以从蓝色光芒看到,有没有更多的滚动。我使用的是默认的Theme.Holo.Light.DarkActionbar,没有任何自定义视图呢。

You can see from the blue glow that there is nothing more to scroll. I'm using the default Theme.Holo.Light.DarkActionbar, without any custom view yet.

为什么这最后一个标签比其他小?我怎样才能确保它得到相同的宽度为其他人呢?

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

推荐答案

事实上,我来到翻过了同样的问题,我周围发现的唯一工作就是禁用选项卡之间的分界线。貌似在本机动作条测量标签栏容器时不走分频器大小的照顾一个bug。

Indeed I came accross the same problem and the only work around I found was to disable the dividers between tabs. Looks like there is a bug in the native actionbar that does not take care of the dividers size when measuring tab bar container.

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

(这里我用actionbarsherlock,但它不是问题的根源,你可以从母公司延长你的风格=@安卓风格/ Widget.Holo.ActionBar.TabBar)

(Here I'm using actionbarsherlock but it is not the source of the problem you could extend your style from parent="@android:style/Widget.Holo.ActionBar.TabBar")

和运用它在你的主题:

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

如果你确实需要的动作条分隔,一个简单的解决方案可能是直接将它添加到的选项卡背景(左或右)

If you absolutely need the actionBar divider, one simple solution may be to add it directly to the tab background (left or right)

这篇关于标签项宽度操作栏(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆