看起来StateListDrawable
会忽略应用于其包含的可绘制对象上的颜色过滤器。例如:
StateListDrawable sld = new StateListDrawable();
Drawable pressedState = Context.getResources().getDrawable(R.drawable.solid_green);
pressedState.setColorFilter(Color.RED, PorterDuff.Mode.SRC);
sld.addState(new int[] {android.R.attr.state_pressed}, pressedState);
// Other states...
如果您将
sld
应用于视图的背景,您会期望当它被按下时,该视图的背景会变成纯红色。然而,实际上它会变成绿色 - 即pressedState
的颜色,没有任何过滤器应用。