Selector常用状态:
android:state_selected 控件选中状态,可以为true或false

android:state_focused 控件获得焦点状态,可以为true或false

android:state_pressed 控件点击状态,可以为true或false

android:state_enabled 控件使能状态,可以为true或false

android:state_checkable 控件可勾选状态,可以为true或false

android:state_checked 控件勾选状态,可以为true或false



设置不同状态下颜色:
btn_enabled.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- 默认 -->
<item android:state_enabled="true">
<color android:color="#e25050" />
</item>
<item android:state_enabled="false">
<color android:color="#908e8e" />
</item>
</selector>

设置不同状态下图片:
btn_pressed.xml

<?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/btn_arrow_left_pressed" />
<item android:state_window_focused="true" android:state_focused="true" android:drawable="@drawable/btn_arrow_left_pressed" />
<item android:state_window_focused="false" android:state_focused="false" android:drawable="@drawable/btn_arrow_left_normal" />
</selector>

更多相关文章

  1. Android(安卓)进程生命周期(Process Lifecycle)
  2. android:layout_weight属性详解
  3. Android应用界面开发_学习笔记_第二周
  4. Android控件Editext、TextView属性详解
  5. Delphi XE7 GPS控件android下的新变化
  6. 【android】 监听去电和来电电话状态
  7. android 手机信息获得
  8. Android(安卓)网络链接状态 网络是否可用
  9. android中LayoutParams设置参数的理解

随机推荐

  1. 【Android】Android上的Jetty
  2. 如何打包你自己的apk程序到Android里?
  3. 学习资源推荐
  4. 控件——SeekBar
  5. Activity的四种启动模式和onNewIntent()
  6. 减少AS占用的C盘空间
  7. android 电池(二):android关机充电流程、充
  8. Android(安卓)开发环境下载地址 -- 百度
  9. Android(安卓)UI开发神兵利器之Android(
  10. android 网络访问-图片处理优秀开源项目