Android ActionBar Sherlock - Remove divider between tabs altogether

梦想的初衷 提交于 2020-01-04 02:04:34

问题


I'm trying to remove the divider between the tabs in an ActionBar (actually an ActionBarSherlock) altogether; i.e. no image between tabs and no gap between the tabs either (I'm using a tiled image background in the tabs). Ideally, I'd like the dividers removed in the XML, rather than in code.

I've tried a few approaches, but nothing seems to be working, such as:

<style name="Theme.MyTheme.ActionBarTab" parent="Widget.Sherlock.ActionBar.TabBar">
    <item name="android:divider">@null</item>
    <item name="divider">@null</item>
    <item name="actionBarDivider">@drawable/empty</item>
    <item name="android:showDividers">none</item>
</style>

回答1:


Turns out I was setting the wrong style. The android:showDividers attribute does work, but when it's applied to the style that inherits from the Widget.Sherlock.ActionBar.TabBar style. So the relevant bits of XML are:

<style name="Theme.Client" parent="Theme.Sherlock.Light.DarkActionBar">
    <item name="android:actionBarTabBarStyle">@style/Theme.Client.ActionBarTabBar</item>
    <item name="actionBarTabBarStyle">@style/Theme.Client.ActionBarTabBar</item>
</style>

<style name="Theme.Client.ActionBarTabBar" parent="Widget.Sherlock.ActionBar.TabBar">
    <item name="android:background">@drawable/tab_bar_bg_tiled</item>
    <item name="background">@drawable/tab_bar_bg_tiled</item>
    <item name="android:showDividers">none</item>
</style>


来源:https://stackoverflow.com/questions/13047417/android-actionbar-sherlock-remove-divider-between-tabs-altogether

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!