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

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

问题描述

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

我能够更改选定项的背景颜色,下拉列表项等的颜色,但不是所选项目的文本颜色......我该怎么办呢?

我的code是: 这是微调,我使用 -

 <微调
                机器人:ID =@ + ID / spinner1
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =32dip
                机器人:背景=@可绘制/ mybg
                机器人:分隔=@可绘制/ list_divider
                机器人:drawSelectorOnTop =真
                机器人:popupBackground =#D3D5D3
                机器人:提示=@字符串/ activityy_prompt
                />
 

这是mybg.xml

 <  - <项目机器人:可绘制=@可绘制/蓝机器人:STATE_ pressed =FALSE/> - >
!<  - <项目机器人:可绘制=@可绘制/ back11/> - >

<项目机器人:可绘制=@可绘制/ greenyellow1机器人:state_focused =真正的机器人:STATE_ pressed =FALSE/>
<项目机器人:可绘制=@可绘制/ greenyellow1机器人:state_focused =真正的机器人:STATE_ pressed =真/>
<项目机器人:可绘制=@可绘制/ greenyellow1机器人:state_focused =假的Andr​​oid版本:STATE_ pressed =真/>
<项目机器人:可绘制=@可绘制/ greenyellow1机器人:state_selected =真/>
<项目机器人:可绘制=@可绘制/ back11/>
 

使用这些我不能够改变selecetd项目的文本颜色...

解决方案

 <项目安卓state_activated =真正的机器人:颜色=@色/红色/>
 

这将改变所选项目颜色在弹出。

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" 
                />

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"/>

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

解决方案

 <item android:state_activated="true" android:color="@color/red"/>

This will change the selected item color in the popup.

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

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