Drawable normal = null; Drawable pressed = null; Drawable focus = null; StateListDrawable stateListDrawable = new StateListDrawable(); // 注意该处的顺序,只要有一个状态与之相配,背景就会被换掉 // 所以不要把大范围放在前面了,如果sd.addState(new[]{},normal)放在第一个的话,就没有什么效果了 stateListDrawable.addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused }, focus); stateListDrawable.addState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled }, pressed); stateListDrawable.addState(new int[] { android.R.attr.state_focused }, focus); stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, pressed); stateListDrawable.addState(new int[] { android.R.attr.state_enabled }, normal); stateListDrawable.addState(new int[] {}, normal);