public static StateListDrawable getClickableDrawable(Context context, Drawable drawable){
ColorDrawable maskDrawable = new ColorDrawable(Color.parseColor("#7de2e2e2"));//EEEEE0
LayerDrawable pressDrawable = new LayerDrawable(new Drawable[]{drawable, maskDrawable});
return MyView.getBackground(drawable, pressDrawable);
}
private static class MyView extends View {
public MyView(Context context) {
super(context);
}
public static StateListDrawable getBackground(Drawable normal,
Drawable pressed) {
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(View.PRESSED_ENABLED_STATE_SET, pressed);
stateListDrawable.addState(View.ENABLED_FOCUSED_STATE_SET, pressed);
stateListDrawable.addState(View.ENABLED_STATE_SET, normal);
stateListDrawable.addState(View.FOCUSED_STATE_SET, pressed);
stateListDrawable.addState(View.EMPTY_STATE_SET, normal);
return stateListDrawable;
}
}