【发布时间】:2013-10-27 21:27:04
【问题描述】:
我不明白为什么我实现的堆叠ActionBar 在最左边的选项卡和屏幕边缘之间存在间隙。
最右边的选项卡不是这种情况。
我尝试通过设置ActionBar 的样式来移除分隔线。在玩了一会儿样式之后,我似乎能够覆盖 TabView 样式的属性,但不能覆盖 ActionBarSherlock 的 TabBar 样式。
<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>
然后我意识到我需要包含相同的无前缀属性。
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+(您可以使用本机 ActionBar 库/样式),是否有使用 ActionBarSherlock 的原因?
-
其实要明确一点,我的 minSdkVersion 实际上低于 14。但我正在过渡到 14。同时,可能导致此问题的原因是什么?
标签: android android-actionbar actionbarsherlock android-styles theming