更改微调器中所选项目的文本颜色 [英] Change text color of selected item in spinner

查看:33
本文介绍了更改微调器中所选项目的文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改微调器中所选项目的字体颜色?

How can I change the font color of the selected item in a spinner?

我可以更改所选项目的背景颜色、下拉项目的颜色等,但不能更改所选项目的文本颜色...我该怎么做?

I am able to change the background color of the selected item, the color of the dropdown item etc, but not the text color of selected item... how can I do that?

我的代码是:这是我正在使用的微调器--:

my code is: this is spinner i am using--:

<Spinner
                android:id="@+id/spinner1"
                android:layout_width="wrap_content"
                android:layout_height="32dip"
                android:background="@drawable/mybg"
                android:divider="@drawable/list_divider"
                android:drawSelectorOnTop="true"
                android:popupBackground="#D3D5D3"
                android:prompt="@string/activityy_prompt" 
                />

这是 mybg.xml

this is mybg.xml

<!-- <item android:drawable="@drawable/blue" android:state_pressed="false"/> -->
<!-- <item android:drawable="@drawable/back11"/> -->

<item android:drawable="@drawable/greenyellow1" android:state_focused="true" android:state_pressed="false"/>
<item android:drawable="@drawable/greenyellow1" android:state_focused="true" android:state_pressed="true"/>
<item android:drawable="@drawable/greenyellow1" android:state_focused="false" android:state_pressed="true"/>
<item android:drawable="@drawable/greenyellow1" android:state_selected="true"/>
<item android:drawable="@drawable/back11"/>

使用这些我无法更改 elecetd 项目的文本颜色...

using these i am not able to change the text color of selecetd item...

推荐答案

drawable/mybg:

drawable/mybg:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_activated="true">
        <color android:color="@color/black" />
    </item>
</layer-list>

这将更改弹出窗口中所选项目的颜色.

This will change the selected item color in the popup.

这篇关于更改微调器中所选项目的文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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