8

这是一个非常具体的问题。我在 onCreate() 方法中添加的 ActionBar 上有一个微调器。我已经能够将文本设置为白色,但我无法让右下角的下划线和三角形/箭头显示为白色。这是我的样式:

<item name="android:actionDropDownStyle">@style/customActionBarDropDownStyle</item>

<style name="customActionBarDropDownStyle" parent="android:style/Widget.Holo.Light.Spinner">
    <item name="android:textColor">#FFFFFF</item>
</style>

我找不到使下划线和三角形变为白色的样式项/属性。一个存在吗?

这是一个例子。我用红色突出显示了我想要变成白色的三角形和下划线。

在此处输入图像描述

4

3 回答 3

7

答案有点晚,但总比没有好:) 您应该创建一个新的 9 补丁可绘制对象并将其设置为 android:actionDropDownStyle 的背景。

这是一个例子:

    <item name="android:actionDropDownStyle">@style/customActionBarDropDownStyle</item>
    <style name="customActionBarDropDownStyle"parent="android:style/Widget.Holo.Light.Spinner">
    <item name="android:background">@drawable/custom_spinner_dropdown</item>
    </style>

您不能为几乎每个原生组件设置颜色,因为它们的背景(在大多数情况下)是 9-patch png。

于 2012-06-15T12:13:30.707 回答
1

actionDropDownStyle 不能用来改变你在actionbar上添加的spinner的样式;它是动作栏模式之一ActionBar.NAVIGATION_MODE_LIST

至于你的问题,你可以在布局文件中为你的微调器定义一个选择器,就像这样:

enter code here
<Spinner
    android:dropDownWidth="200dp"
    android:background="@drawable/actionbar_spinner"
    android:id="@+id/action_spinner"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginRight="10dp" />
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false"
        android:drawable="@drawable/spinner_ab_disabled" />
    <item android:state_pressed="true"
        android:drawable="@drawable/spinner_ab_pressed" />
    <item android:state_pressed="false" android:state_focused="true"
        android:drawable="@drawable/spinner_ab_focused" />
    <item android:drawable="@drawable/spinner_ab_default" />
</selector>
于 2013-07-25T09:36:42.947 回答
0

尝试这个 :android:background="@null"

于 2015-06-27T05:54:13.957 回答