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

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

问题描述

在您从下拉列表中选择一个项目后,我正在尝试更改微调按钮中显示的单个项目的文本颜色.我已经研究了 Android SDK 中的 themes.xml 和 style.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.

澄清一下,我不是在尝试更改下拉项的颜色,而是在没有下拉列表时尝试更改微调器显示文本的颜色.我想你可以称之为微调器的按钮"文本.

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.

推荐答案

我觉得style.xml 里大概有这个

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 =- 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天全站免登陆