标签:
public static StateListDrawable makeSelector(Context context, int idNormal, int idPressed, int idFocused) {
StateListDrawable bg = new StateListDrawable();
Drawable normal = context.getResources().getDrawable(idNormal);
Drawable pressed = context.getResources().getDrawable(idPressed);
Drawable focused = context.getResources().getDrawable(idFocused);
bg.addState(new int[]{android.R.attr.state_pressed,}, pressed);
bg.addState(new int[]{android.R.attr.state_focused}, focused);
bg.addState(new int[]{}, normal);
return bg;
}
注意: 1.normal state要在最后add
2.要使用button测试
标签:
原文地址:http://www.cnblogs.com/songsyl1207/p/4894105.html