ActionBarSherlock stacked action bar styling issue

怎甘沉沦 提交于 2019-11-26 08:35:45

问题


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

This is not the case with the right most tab.

\"Right

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?


回答1:


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>



回答2:


I will accept anyone with an answer that involves keeping ActionBarSherlock, however, I removed this library and now I am just using the support libraries and am no longer having that spacing issue. I guess there might be an issue with ActionBarSherlock. But since it is no longer being supported I think the best solution is just to use the Support libraries.



来源:https://stackoverflow.com/questions/19623805/actionbarsherlock-stacked-action-bar-styling-issue

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