Android:Spinner小部件的文本颜色属性隐藏在哪里? [英] Android: Where is the Spinner widget's text color attribute hiding?

查看:282
本文介绍了Android:Spinner小部件的文本颜色属性隐藏在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在您从下拉列表中选择一个项目后,我想更改显示在微调框按钮中的单个项目的文字颜色。我一直在Android SDK中仔细阅读themes.xml和styles.xml一个小时,我似乎找不到Spinner从哪里得到颜色值。

I'm trying to change the text color of the single item that is displayed in the spinner button after you select an item from the dropdown. I've been perusing the themes.xml and styles.xml in the Android SDK for an hour now, and I can't seem to find where the Spinner is getting the color value from.

为了说明,我不是试图改变下拉项目的颜色,我试图改变当没有下拉菜单时微调框显示的文本的颜色。我想你可以把它叫做微调器的'button'文本。

To clarify, I'm NOT trying to change the color of a dropdown item, I'm trying to change the color of the spinner's displayed text when there is no dropdown. I guess you could call it the spinner's 'button' text.

推荐答案

p>

I think it's probably this bit in styles.xml

<style name="Widget.TextView.SpinnerItem">
    <item name="android:textAppearance">@style/TextAppearance.Widget.TextView.SpinnerItem</item>
</style>
<style name="Widget.DropDownItem.Spinner">
    <item name="android:checkMark">?android:attr/listChoiceIndicatorSingle</item>
</style>

- = EDIT = -
结果如下:

-= EDIT =- Here's the result:

以下是操作方法:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MooTheme" parent="android:Theme">
        <item name="android:spinnerItemStyle">@style/MooSpinnerItem</item>
    </style>

    <style name="MooSpinnerItem" parent="android:Widget.TextView.SpinnerItem">
        <item name="android:textAppearance">@style/MooTextAppearanceSpinnerItem</item>
    </style>

    <style name="MooTextAppearanceSpinnerItem" parent="android:TextAppearance.Widget.TextView.SpinnerItem">
        <item name="android:textColor">#F00</item>
    </style>
</resources>

然后只需将其添加到AndroidManifest.xml中的应用程序标记

Then just add this to the application tag in your AndroidManifest.xml

android:theme="@style/MooTheme"

这篇关于Android:Spinner小部件的文本颜色属性隐藏在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆