设置背景颜色上的选择微调项目 [英] Setting background color for Spinner Item on selection

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

问题描述

我使用的是微调控制在我的code 。我想这个项目得到突出显示(即,改变了该项目的背景色)的选择。如何才能实现这一目标?

I am using the Spinner control in my code. I want the item to get highlighted (i.e., background color changed for that item) on selection. How can this be achieved?

推荐答案

创建XML:为前:mybg.xml

create a xml: for ex:mybg.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:drawable="@color/anyColor" />
<item android:drawable="@android:color/transparent" />
</selector>

和在活动XML

DO

  <Spinner...............
  android:drawSelectorOnTop="true"
  android:background="@drawable/mybg"/>  

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

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