StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[] { android.R.attr.state_selected }, context
.getResources().getDrawable(R.mipmap.ic_control_light_close_gray));
drawable.addState(new int[] { android.R.attr.state_pressed }, context
.getResources().getDrawable(R.mipmap.ic_control_light_close_gray));
drawable.addState(new int[] { android.R.attr.state_enabled }, context
.getResources().getDrawable(R.mipmap.ic_control_light_close_gray));
drawable.addState(new int[] { android.R.attr.state_pressed }, BaseActivity.currentActivity
.getResources().getDrawable(R.mipmap.ic_control_light_close_gray));
drawable.addState(new int[] {}, BaseActivity.currentActivity
.getResources().getDrawable(ic_control_normal));
imageView.setImageDrawable(drawable);
//imageView.setBackground(drawable)// 安卓版本必须4.1及以上
StateListDrawable代码替换selector点击效果
最新推荐文章于 2022-07-14 21:37:43 发布