【问题标题】:Android Change spinner pressed colour Light Holo themeAndroid 更改微调器按下颜色 Light Holo 主题
【发布时间】:2012-01-27 21:19:31
【问题描述】:

我正在开发一款 Android 平板电脑应用。我创建了一个自定义操作栏,并设法按照我想要的方式设置它的样式,除了微调器。

我的主题扩展了 Holo Light,这意味着当我按下微调器时,它会变成蓝色。我该如何更改?

【问题讨论】:

    标签: android android-widget spinner android-3.0-honeycomb android-4.0-ice-cream-sandwich


    【解决方案1】:

    在您的主题中为 android:actionDropDownStyle 指定自定义样式,该主题本身具有用于您的自定义状态列表可绘制对象的 android:background。

    这是默认指定的:

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_enabled="false"
              android:drawable="@drawable/spinner_ab_disabled_holo_dark" />
        <item android:state_pressed="true"
              android:drawable="@drawable/spinner_ab_pressed_holo_dark" />
        <item android:state_pressed="false" android:state_focused="true"
              android:drawable="@drawable/spinner_ab_focused_holo_dark" />
        <item android:drawable="@drawable/spinner_ab_default_holo_dark" />
    </selector>
    

    您需要为这些状态中的每一种(以及 mdpi、hdpi 和 xhdpi)提供自己的图像。

    您可以修改平台附带的内容,让您的生活更轻松。在drawable-mdpi、drawable-hdpi 和drawable-xhdpi 文件夹中查看SDK/platforms/platform-14/data/res/。

    【讨论】:

    • 我在我的主题中添加了以下内容 @style/MySpinner 然后创建了 ​​@drawable/spinner_background 这似乎不起作用。将 spin_background 可绘制对象作为背景添加到 xml 布局中的微调器时,它可以工作。所以我可以排除drawable的问题。
    猜你喜欢
    • 1970-01-01
    • 2012-10-26
    • 1970-01-01
    • 1970-01-01
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多