【问题标题】:Android Honeycomb: How to style right corner arrow in spinner on an ActionBarAndroid Honeycomb:如何在 ActionBar 上的微调器中设置右角箭头的样式
【发布时间】:2015-06-27 13:58:07
【问题描述】:

这是一个非常具体的问题。我在 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>

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

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

【问题讨论】:

  • 您找到解决方案了吗?
  • 不,我还没有找到办法。

标签: android spinner android-3.0-honeycomb android-actionbar


【解决方案1】:

答案有点晚,但总比没有好:) 您应该创建一个新的 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。

【讨论】:

    【解决方案2】:

    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>
    

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-01
        • 1970-01-01
        • 2012-02-15
        • 1970-01-01
        相关资源
        最近更新 更多