Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

android - ActionBarSherlock stacked action bar styling issue

I can't figure out why the stacked ActionBar I have implemented has a gap between the left most tab and the edge of the screen.

Left most tab has left divider issue

This is not the case with the right most tab.

Right most tab does not have divider issue

I tried to remove the dividers by styling the ActionBar. After playing around with styles for a little bit, it seems like I am able to override attributes of the TabView style but not the TabBar style of ActionBarSherlock.

<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>

Then I realized I need to include identical unprefixed attributes.

ActionBarSherlock Theming

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.

But I tried to include identical unprefixed attributes but that didnt work for me.

I tried to include identical unprefixed attributes.

<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>

But it throws an error

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

So then i removed those two attributes and tried to run it again, but i still see the tabbar dividiers.

<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>

In my AndroidManifest.xml file, I included

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18"/>

Any suggestions or thoughts about what may be the issue?

Update

I also tried

<style name="Theme.Dark" parent="@style/Theme.Sherlock.Light.DarkActionBar">
    <item name="actionBarDivider">@null</item>
    <item name="android:actionBarDivider">@null</item>
</style>

But this didn't remove the dividers either. Is there another attribute which overrides these attributes?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have to change the android:actionBarDivider attribute which belongs to the theme, not to the action bar style android:divider. You can remove the divider like this:

<style name="AppTheme" parent="Theme.Sherlock">
    <item name="actionBarDivider">@null</item>
    <item name="android:actionBarDivider">@null</item>
</style>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...