selector
一、selector详解:
在res/drawable文件夹新增一个文件,此文件设置了图片的触发状态,你可以设置 state_pressed,state_checked,state_pressed,state_selected,state_focused,state_enabled 等几个状态:
android:state_pressed
如果是true,当被点击时显示该图片,如果是false没被按下时显示默认。
android:state_focused
true,获得焦点时显示;false,没获得焦点显示默认。
android:state_selected
true,当被选择时显示该图片;false,当未被选择时显示该图片。
android:state_checkable
true,当CheckBox能使用时显示该图片;false,当CheckBox不能使用时显示该图片。
android:state_checked
true,当CheckBox选中时显示该图片;false,当CheckBox为选中时显示该图片。
android:state_enabled
true,当该组件能使用时显示该图片;false,当该组件不能使用时显示该图片。
android:state_window_focused
true,当此activity获得焦点在最前面时显示该图片;false,当没在最前面时显示该图片。
二、例子:
选中点击时,显示:drawable/button_pressed
获得焦点时,显示:drawable/button_focused
默认状态时,显示:drawable/button_normal
<?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 -->
<item android:drawable="@drawable/button_normal"/><!-- default -->
</selector>
分享到:
相关推荐
<item name="android:button">@drawable/selector</item>//这个selector.xml中就是对应不同状态的CheckBox的背景图片 3:在selector.xml <selector xmlns:android=...
在drawable中配置Android的selector。将如下的XML文件保存成你自己命名的.xml文件(比如item_bg.xml),并将该文件放置在drawable文件中,在系统使用时根据ListView中的列表项的状态来使用相应的背景图片。 代码如下...
3.3. 用 logback-test.xml 或 logback.xml 自动配置 ............................................... 19 3.4. 自动打印警告和错误消息 ...........................................................................
1. 目录 1. 2. 目录 .........................................................................................................................................................1 JVM ........................
:red_heart_selector: SPA, 扁平主题。 概要 预习 产品特点 带SPA 自定义重点颜色,背景,字体,暗模式 自定义代码语法突出显示 搜索 评论 支持大多数评论系统作为插件 增强的内容显示 缩图 首字下沉 可缩放的...
更多配置XML 配置在XML中使用AdLoopView,可以有如下配置:<com.kevin.loopview.AdLoopView android:id="@ id/adloop_act_adloopview" android:layout_width="match_parent" android:layout_height="192dp...
mybatis-generator的配置文件是generatorConfig.xml,里面有完整的注释,这里就不多讲了 datasource.properties中配置mysql.jar包时需要使用绝对路径,如果有人要直接复制我的代码的话请修改路径 在mapper文件中对...
可以将代码中的字符串写在string.xml文件中 这个插件还可以自动书写findViewById 32.Material Theme UI 添加Material主题到你的AS 33..ignore 我 们都知道在Git 中想要过滤掉一些不想提交的文件,可以把...
如果站点的_config.yml文件中存在以下配置变量,该插件将自动使用以下任何配置变量。 title或name -网站的标题,例如“我的真棒网站” description对您的网站的详细描述,例如,“我在哪里写有关Jekyll和其他令人...
6.4.1 元素选择符Selector 6.4.2 属性选择符Attributes Selectors 6.4.3 CSS值元素选择符 6.4.4 Ext.query与Ext.select 6.5 应用模板 6.5.1 Ext.Template 6.5.2 Ext.XTemplate 第7章 设计表单类布局 7.1 ...
6.4.1 元素选择符Selector 6.4.2 属性选择符Attributes Selectors 6.4.3 CSS值元素选择符 6.4.4 Ext.query与Ext.select 6.5 应用模板 6.5.1 Ext.Template 6.5.2 Ext.XTemplate 第7章 设计表单类布局 7.1 ...
设置view的圆角和背景一般都是在xml里面通过selector的配置文件来写的。在项目中有个需求,背景颜色是从网络获取的,而且要设置为圆角,想了一下,通过xml的形式貌似实现不了,只能通过代码分别设置,就只能重写...
摘要:Java源码,Android源码,Android源码,Selecter Android Selecter Drawable属性使用源码下载,android的selector是在drawable/xxx.xml中配置的,android的selector是一个背景选择器,美化软件时候经常用到,这个...
{2.8}框架中移动的小球}{59}{section.2.8} {2.9}抽象与接口}{59}{section.2.9} {2.10}访问控制}{60}{section.2.10} {2.10.1}类的属性}{60}{subsection.2.10.1} {2.10.2}类的方法}{61}{subsection.2.10.2} {...
7.2.6 在XML中使用属性动画 170 7.2.7 View的animate方法 170 7.3 Android布局动画 171 7.4 Interpolators(插值器) 171 7.5 自定义动画 172 7.6 Android 5.X SVG矢量动画机制 175 7.6.1 标签 175 7.6.2 SVG...
svg-url-loader 一个Webpack...支持的参数可以在url中或从webpack配置文件中传递参数。 见的WebPack文档中的部分获取更多细节。 还支持使用resourceQuery传递参数: . selector { background-image : url(.. / assets/
如果要实现圆角图片,并变色须在drawable中配置背景文件如下: <?xml version=1.0 encoding=utf-8?> <selector xmlns:android=http://schemas.android.com/apk/res/android> <shape xmlns:android=...
Android XML绘图(Shape、Layer、Selector) Android Canvas绘图(canvas、point、porterDuffXfermode、shader) Android 动画详解 Android 自定义控件 今天就当开胃菜,先讲讲最简单的xml绘图,相信这个大家...
--默认配置--> name="text" format="reference|string" /> <!--按钮文字颜色--> name="textColor" format="reference|color" /> <!--按钮文字大小--> name="textSize" format=...
initAndRegister,创建Channel,初始化配置Channel,将Channel XML到EventLoop(事件插入器Selector); doBind0,调用JDK可以通过API将端口与initAndRegister创建好的Channel进行绑定,并添加监听器。 创建一个...