Android-StateListDrawable(状态选择器)
StateListDrawable(状态选择器)
作用:StateListDrawable是在XML中定义的一个可绘制(drawable)的对象,它可以根据状态的不同为同一个图形更换不同的图片
用法:对应于XML文件中的selector
语法
<?xml version="1.0" encoding="utf-8"?>
android:dither=[“true” | “false”]
android:variablePadding=[“true” | “false”] >
item里面的Drawable的状态判定
android:state_pressed
按下的状态,(按下但是还没松开)
android:state_focused
当前View获取了焦点
android:state_selected
用户选择了当前View
android:state_checked
用户选中了View,一般用于CheckBox这种非黑即白的选项
android:state_enabled
当前View处于可用的状态
android:state_hovered
光标是否悬停,通常与focused state相同,它是4.0的新特性
android:state_checkable
组件是否能被check。如:RadioButton是可以被check的。
android:state_activated
是否被激活
android:state_window_focused
应用程序是否在前台,当有通知栏被拉下来或者一个对话框弹出的时候应用程序就不在前台了
特点
1、item可以用多个,item里面放的是Drawable
2、系统查找顺序是顺着item从上到下直到找到就停止往下寻找。
圆形的点击变换颜色
<?xml version="1.0" encoding="utf-8"?>Edittext的背景框和焦点变化 Edittext输入框 xmlns:android=“http://schemas.android.com/apk/res/android”>xmlns:android="http://schemas.android.com/apk/res/android">
更多相关文章
随机推荐