selector 的用法,在选择和不选择情况下的颜色
在res/drawable文件夹新增一个文件,此文件设置了图片的触发状态,你可以设置 state_pressed,state_checked,state_pressed,state_selected,state_focused,state_enabled 等几个状态:
android:state_pressed
Boolean. "true" if this item should be used when the object is pressed (such as when a button is touched/clicked); "false" if this item should be used in the default, non-pressed state.
如果是true,当被点击时显示该图片,如果是false没被按下时显示默认。
android:state_focused
Boolean. "true" if this item should be used when the object is focused (such as when a button is highlighted using the trackball/d-pad); "false" if this item should be used in the default, non-focused state.
true,获得焦点时显示;false,没获得焦点显示默认。
android:state_selected
Boolean. "true" if this item should be used when the object is selected (such as when a tab is opened); "false" if this item should be used when the object is not selected.
true,当被选择时显示该图片;false,当未被选择时显示该图片。
android:state_checkable
Boolean. "true" if this item should be used when the object is checkable; "false" if this item should be used when the object is not checkable. (Only useful if the object can transition between a checkable and non-checkable widget.)
true,当CheckBox能使用时显示该图片;false,当CheckBox不能使用时显示该图片。
android:state_checked
Boolean. "true" if this item should be used when the object is checked; "false" if it should be used when the object is un-checked.
true,当CheckBox选中时显示该图片;false,当CheckBox为未选中时显示该图片。
android:state_enabled
Boolean. "true" if this item should be used when the object is enabled (capable of receiving touch/click events); "false" if it should be used when the object is disabled.
true,当该组件能使用时显示该图片;false,当该组件不能使用时显示该图片。
android:state_window_focused
Boolean. "true" if this item should be used when the application window has focus (the application is in the foreground), "false" if this item should be used when the application window does not have focus (for example, if the notification shade is pulled down or a dialog appears).
true,当此activity获得焦点在最前面时显示该图片;false,当没在最前面时显示该图片。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed"/><!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/button_focused"/><!-- focused -->
<itemandroid:drawable="@drawable/button_normal"/><!-- default -->
</selector>
selector 的用法,在选择和不选择情况下的颜色的更多相关文章
- ios 地图,系统升级为12后,进入地图,大头针全部默认展开问题,以及在选择不同距离的情况下,如何刷新地图的区域范围
1.第一个问题,大头针在ios12,默认展开问题,需要设置大头针视图的默认选中属性为NO - (MKAnnotationView *)mapView:(MKMapView *)mapView view ...
- Selector API用法
java.nio.channels 类 Selector java.lang.Object java.nio.channels.Selector 直接已知子类: AbstractSelector pu ...
- Android菜鸟成长记9 -- selector的用法
在项目开发的时候,由于系统给出的控件不够美观,因此开发时领导常常要我更改下界面,用美工给的图片取代系统图片.开始时,我只是给按钮等设置一下背景图片,这样做虽然美观了,但界面看起来却比较死板,比如用户点 ...
- CSS选择符-----元素选择符
通配选择符(*) 选定所有对象 通配选择符(Universal Selector) 通常不建议使用通配选择符,因为它会遍历并命中文档中所有的元素,出于性能考虑,需酌情使用 & ...
- Sql Server优化之索引提示----我们为什么需要查询提示,Sql Server默认情况下优化策略选择的不足
环境: Sql Server2012 SP3企业版,Windows Server2008 标准版 问题由来: 最近在做DB优化的时候,发现一个存储过程有非常严重的性能问题, 由于整个SP整体逻辑是一个 ...
- Pandas之容易让人混淆的行选择和列选择
在刚学Pandas时,行选择和列选择非常容易混淆,在这里进行一下讨论和归纳 本文的数据来源:https://github.com/fivethirtyeight/data/tree/master/fa ...
- 选择Android还是选择JavaEE?
很多同学咨询过同样的一个问题,该问题也是最备受争议的问题,那就是到底是选择Android还是选择JavaEE.下面发表一些本人的看法. Android属于一个特有的Java技术应用,专注于 ...
- SEL数据类型,@selector的用法,以及调用SEL
1.SEL数据类型 SEL是个指针类型的数据,类似C语言中的函数指针.在OC中,每个对象方法都有其对应着一个SEL变量.当我们调用对象方法时,编译器会将该方法转换成一个SEL的数据,然后去类中寻找该方 ...
- JS-加载页面的时候自动选择刚才所选择option
<body class="no-skin" onload="option_auto(${pd.PACK_SORT})"> <select na ...
随机推荐
- 安装和使用的django的debug_toolbar
安装和使用的django的debug_toolbar Django Debug Toolbar安装 安装Django Debug Toolbar pip install django-debug-to ...
- 两套JRE
JDK就是Java Development Kit.简单的说JDK是面向开发人员使用的SDK,它提供了Java的开发环境和运行环境. SDK是Software Development Kit 一般指软 ...
- ssh(sturts2_spring_hibernate) 框架搭建之spring
一.spring总结: ⑴.spring是一个轻量级的JAVA开发框架,主要的作用是用来管理实例(可以解决JAVA类中new对象的问题,节省内存资源.)和降低代码之间的耦合性,促进代码模块化. ⑵.促 ...
- BrowserSync前端调试工具使用
上次介绍了一款DebugGap移动端调试工具DebugGap推荐.但是这几天使用了之后感觉还是有些不足,尤其是里面的调试工具虽然和Chrome里面的调试长的很像,但是多少有些不同,使用起来还是不太方便 ...
- C# yeild使用
C# yeild的两种形式的yield语句: yield return <expression>; yield break; 使用 yield return 语句每一次返回每个元素. 将使 ...
- 浏览器端获取局域网IP地址,本机的MAC,以及机器名
原文链接:http://www.orlion.ga/59/ 只针对IE且客户端的IE允许AcitiveX运行 code: <html> <head> <title> ...
- Android实现下滑和上滑事件
做过开发的对于下滑刷新与上滑加载都一定不陌生,因为我们在很多时候都会使用到,那对对于这个效果如何实现呢?相信难道过很多小伙伴,今天我就带领大家一道通过第三方组件快速完成上述效果的实现,保准每位小伙伴都 ...
- 拓扑排序(三)之 Java详解
前面分别介绍了拓扑排序的C和C++实现,本文通过Java实现拓扑排序. 目录 1. 拓扑排序介绍 2. 拓扑排序的算法图解 3. 拓扑排序的代码说明 4. 拓扑排序的完整源码和测试程序 转载请注明出处 ...
- php基础教程-数据类型
PHP 支持八种原始类型(type). 四种标量类型: string(字符串) integer(整型) float(浮点型,也作 double ) boolean(布尔型) 两种复合类型: array ...
- Elasticsearch之_default_—— 为索引添加默认映射
前篇说过,ES可以自动为文档设定索引.但是问题也来了——如果默认设置的索引不是我们想要的,该怎么办呢? 要知道ES这种搜索引擎都是以Index为实际的分区,Index里面包含了不同的类型,不同的类型是 ...