继承关系
- ColorStateList
.
|--Object
├─ColorStateList
- StateListDrawable
.
|--Object
| ├─Drawable
| ├─ColorDrawable
| ├─**StateListDrawable**
用法
ColorStateList
多状态颜色的ColorStateList
java:
// 颜色数组 int[] colors = new int[]{color, color1, color2, color3, color4, color5}; // 颜色数组对应的状态 int[][] states = new int[6][]; states[0] = new int[]{android.R.attr.state_checked, android.R.attr.state_enabled}; states[1] = new int[]{android.R.attr.state_enabled, android.R.attr.state_focused}; states[2] = new int[]{android.R.attr.state_enabled}; states[3] = new int[]{android.R.attr.state_focused}; states[4] = new int[]{android.R.attr.state_window_focused}; states[5] = new int[]{}; ColorStateList colorList = new ColorStateList(states, colors)
xml:
<!--test.xml--> <?xml version=&