colordrawable

Create a new color drawable

时光总嘲笑我的痴心妄想 提交于 2019-12-31 08:26:37
问题 I am trying to convert a hex value to an int so I can create a new color drawable. I'm not sure if this is possible, but according to the documentation, it should. It plainly asks for public ColorDrawable (int color) Added in API level 1 Creates a new ColorDrawable with the specified color. Parameters color The color to draw. So, my code isn't working because I'm getting an Invalid int: "FF6666" error. Any ideas? int decode = Integer.decode("FF6666"); ColorDrawable colorDrawable = new

Create a new color drawable

随声附和 提交于 2019-12-02 16:28:24
I am trying to convert a hex value to an int so I can create a new color drawable. I'm not sure if this is possible, but according to the documentation , it should. It plainly asks for public ColorDrawable (int color) Added in API level 1 Creates a new ColorDrawable with the specified color. Parameters color The color to draw. So, my code isn't working because I'm getting an Invalid int: "FF6666" error. Any ideas? int decode = Integer.decode("FF6666"); ColorDrawable colorDrawable = new ColorDrawable(decode); Since you're talking about hex you have to start with 0x and don't forget the opacity.