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; } }
方便好用的自定义按钮按下效果
猜你喜欢
转载自yangzc106.iteye.com/blog/1896863
今日推荐
周排行