安卓中 选择器属性的使用,注意事项
来源:互联网 发布:usb端口坏了怎么办 编辑:程序博客网 时间:2024/06/05 07:25
处理android:state_activity 同一个界面出现需要同时选择两个焦点的时候,用到
http://blog.csdn.net/singleton1900/article/details/22494503
我们在定义一个drawable的时候可以通过xml定义的drawable对象。它使得一个图片能在不同的状态下显示不同的图案,比如一个Button,它有pressed,focused,或者其它状态,通过使用state list drawable,你就可以为每种状态提供不同的图片。
先看一个范例:
XML file saved at res/drawable/button.xml
:
- <?xml version="1.0" encoding="utf-8"?>
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="true" android:state_enabled="true" android:state_window_focused="false"
- android:drawable="@drawable/button_pressed" /> <!-- pressed,enable等多个属性 -->
- <item android:state_focused="true"
- android:drawable="@drawable/button_focused" /> <!-- focused -->
- <item android:state_hovered="true"
- android:drawable="@drawable/button_focused" /> <!-- hovered -->
- <item android:drawable="@drawable/button_normal" /> <!-- default -->
- </selector>
This layout XML applies the state list drawable to a Button:
- <Button
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:background="@drawable/button" />
android:drawable 放一个drawable资源
android:state_pressed 是否按下,如一个按钮触摸或者点击。
android:state_focused 是否取得焦点,比如用户选择了一个文本框。
android:state_hovered 光标是否悬停,通常与focused state相同,它是4.0的新特性
android:state_selected 被选中,它与focus state并不完全一样,如一个list view 被选中的时候,它里面的各个子组件可能通过方向键,被选中了。
android:state_checkable 组件是否能被check。如:RadioButton是可以被check的。
android:state_checked 被checked了,如:一个RadioButton可以被check了。
android:state_enabled 能够接受触摸或者点击事件
android:state_activated 被激活(这个麻烦举个例子,不是特明白)
android:state_window_focused 应用程序是否在前台,当有通知栏被拉下来或者一个对话框弹出的时候应用程序就不在前台了
注意:如果有多个item,那么程序将自动从上到下进行匹配,最先匹配的将得到应用。(不是通过最佳匹配)
如果一个item没有任何的状态说明,那么它将可以被任何一个状态匹配。
详细的请看官方的API,那里写的更详细~!http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
- 安卓中 选择器属性的使用,注意事项
- jQuery属性选择器的使用
- jQuery-使用选择器注意事项
- CSS 属性选择器 模糊匹配的使用
- css3中属性选择器的使用
- css 选择器使用之注意事项
- jQuery 和 prototype 选择器的使用与注意事项
- TD的noWrap属性使用注意事项
- TD的noWrap属性使用注意事项
- TD的noWrap属性使用注意事项
- TD的noWrap属性使用注意事项
- 属性选择器的应用
- jQuery 的属性选择器
- CSS3的属性选择器
- CSS3的属性选择器
- jquery使用属性相等选择器
- jquery属性选择器使用事例
- jQuery-Selectors(选择器)的使用(六、属性篇)
- 计数排序
- Ruby 元编程
- Raphael.js API之Element.id,Element.insertAfter(),Element.insertBefore(),Element.hide(),Paper.clear(),
- UITabBarController TabBar初始化
- 我不是不担心你
- 安卓中 选择器属性的使用,注意事项
- Javaee7标准websocket实践
- 快速排序
- tomcat的maxThreads、acceptCount(最大线程数、最大排队数)
- IOS技术关键点
- boost::thread线程创建方式总结
- sencha touch 集成了cordova以后需要注意的问题
- 1111
- PMON学习笔记