3

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

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>

我也尝试过将分隔符属性更改为颜色或可绘制。但是下拉菜单导航中仍然存在分隔符,完全没有效果。任何想法都会非常有帮助。

4

2 回答 2

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>
于 2012-10-23T15:55:21.760 回答
1

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

<style name="YourThemeDropDownListView" parent="Widget.Sherlock.ListView.DropDown">
    <item name="android:divider">@color/White</item
    <item name="android:dividerHeight">5dp</item>
</style>
于 2014-03-20T10:24:10.137 回答