ActionBarSherlock 堆叠式操作栏样式问题

5
我无法理解为什么我实现的堆叠式ActionBar在最左边的选项卡和屏幕边缘之间有一个间隙。

Left most tab has left divider issue

右侧的选项卡不是这种情况。

Right most tab does not have divider issue

我试图通过为ActionBar设置样式来去除分隔符。经过一番试验,似乎我能够覆盖TabView样式的属性,但无法覆盖ActionBarSherlockTabBar样式。
<style name="ActionBarTabBarStyle.Dark" parent="@style/Widget.Sherlock.ActionBar.TabBar">
    <item name="android:divider">@null</item>
    <item name="android:showDividers">none</item>
    <item name="android:dividerPadding">0dip</item>
</style>

然后我意识到我需要包含相同的未加前缀属性。

ActionBarSherlock主题化

Due to limitations in Android's theming system any theme customizations must be declared 
in two attributes. The normal android-prefixed attributes apply the theme to the native 
action bar and the unprefixed attributes are for the custom implementation. Since both 
theming APIs are exactly the same you need only reference your customizations twice rather 
than having to implement them twice.

但我尝试包含相同的未添加前缀的属性,但对我来说没有起作用。

我尝试包含相同的未添加前缀的属性。

<style name="ActionBarTabBarStyle.Dark" parent="@style/Widget.Sherlock.ActionBar.TabBar">
    <item name="android:divider">@null</item>
    <item name="android:showDividers">none</item>
    <item name="android:dividerPadding">0dip</item>
    <item name="divider">@null</item>
    <item name="showDividers">none</item>
    <item name="dividerPadding">0dip</item>
</style>

但它会抛出一个错误

Error: No resource found that matches the given name: attr 'dividerPadding'.
Error: No resource found that matches the given name: attr 'showDividers'.

所以我移除了这两个属性并尝试再次运行,但是我仍然看到了选项卡栏的分隔线。
<style name="ActionBarTabBarStyle.Dark" parent="@style/Widget.Sherlock.ActionBar.TabBar">
    <item name="android:divider">@null</item>
    <item name="android:showDividers">none</item>
    <item name="android:dividerPadding">0dip</item>
    <item name="divider">@null</item>
</style>

在我的AndroidManifest.xml文件中,我包含了。
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18"/>

任何关于问题可能是什么的建议或想法?
更新
我也尝试了。
<style name="Theme.Dark" parent="@style/Theme.Sherlock.Light.DarkActionBar">
    <item name="actionBarDivider">@null</item>
    <item name="android:actionBarDivider">@null</item>
</style>

但这也没有去除分隔符。是否还有其他属性可以覆盖这些属性?

如果您的应用程序版本是v14+,为什么要使用ActionBarSherlock(您可以使用本地的ActionBar库/样式)? - ianhanniballake
实际上,要明确一点,我的minSdkVersion实际上低于14。但是我正在过渡到14。与此同时,可能会导致这个问题的原因是什么? - Etienne Lawlor
2个回答

1
您需要更改属于主题的 android:actionBarDivider 属性,而不是操作栏样式 android:divider。您可以像这样删除分隔符:
<style name="AppTheme" parent="Theme.Sherlock">
    <item name="actionBarDivider">@null</item>
    <item name="android:actionBarDivider">@null</item>
</style>

我不明白为什么要发布与我的答案完全相同的答案。 - marsei

0

我会接受任何解决方案,只要涉及保留ActionBarSherlock,但是我已经删除了这个库,现在只使用支持库,不再有间距问题。我猜可能是ActionBarSherlock存在问题。但由于它不再得到支持,我认为最好的解决方案就是使用支持库。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接