Add Color “#e3bb87” to StateListDrawable programmatically

ε祈祈猫儿з 提交于 2019-12-06 04:46:12

You can use this:

states.addState(new int[] {android.R.attr.state_pressed},
    new ColorDrawable(Color.parseColor("#e3bb87")));

I think you are looking for ColorDrawable

you can do something like this:

StateListDrawable states = new StateListDrawable();
int color = 0xff00ff00;
states.addState(new int[] {android.R.attr.state_pressed},
     new ColorDrawable(color)); 

The method would be

new ColorDrawable(Color.parseColor("#e3bb87"))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!