似乎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
没有应用过滤器的颜色。