Action Bar Sherlock下拉旋转器分隔器

时间:2012-07-16 11:50:30

标签: android android-actionbar

如何在操作栏下拉菜单导航中隐藏分隔线? 这是我要隐藏的分隔符:

http://s10.postimage.org/4sjqjxltl/4nk4k.png

我尝试了以下样式:

<style name="MyActionBar" parent="Widget.Sherlock.Light.ActionBar">
    <item name="android:background">@drawable/actionbar_bg_shape</item>
    <item name="background">@drawable/actionbar_bg_shape</item>

    <item name="android:showDividers">none</item>
    <item name="android:divider">#00000000</item>
    <item name="android:cacheColorHint">#00000000</item>
    <item name="android:dividerHeight">0px</item>

</style>



<style name="MyDropDownNav" parent="Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:background">@drawable/actionbar_bg_shape</item>
    <item name="android:popupBackground">@drawable/actionbar_dropdown_bg_shape</item>
    <item name="android:dropDownSelector">@drawable/dropdown_nav_selector</item>

    <item name="android:dropDownWidth">175dp</item>
    <item name="android:dropDownHeight">50dp</item>
    <item name="android:showDividers">none</item>
    <item name="android:divider">@null</item>
    <item name="android:cacheColorHint">#00000000</item>
    <item name="android:dividerHeight">0px</item>


    <item name="background">@drawable/actionbar_bg_shape</item>
</style>

<style name="Theme.Test.ICS" parent="Theme.Sherlock.Light">
   <item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
   <item name="actionDropDownStyle">@style/MyDropDownNav</item>
   <item name="android:actionBarStyle">@style/MyActionBar</item>
   <item name="actionBarStyle">@style/MyActionBar</item>

    <item name="actionBarDivider">@drawable/icon</item>
    <item name="android:actionBarDivider">@drawable/icon</item>

</style>

我也试过将divider属性更改为color或drawable。 但是分频器仍然存在于下拉菜单导航中,完全没有效果。任何想法都会非常有用。

2 个答案:

答案 0 :(得分:7)

您需要像这样扩展Widget.Sherlock.ListView.DropDown样式:

<style name="Theme.YourTheme" parent="Theme.Sherlock">
    <item name="dropDownListViewStyle">@style/YourThemeDropDownListView</item>
    <item name="android:dropDownListViewStyle">@style/YourThemeDropDownListView</item>
</style>

<style name="YourThemeDropDownListView" parent="Widget.Sherlock.ListView.DropDown">
    <item name="android:divider">@null</item>
</style>

答案 1 :(得分:1)

值得注意的是,必须指定分隔符高度来编辑分隔符的颜色。

<style name="YourThemeDropDownListView" parent="Widget.Sherlock.ListView.DropDown">
    <item name="android:divider">@color/White</item
    <item name="android:dividerHeight">5dp</item>
</style>