该Resources.getColor(int id)方法已被弃用.
@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException {
return getColor(id, null);
}
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
android android-resources android-mnc android-6.0-marshmallow
我试图将十六进制值转换为int,以便我可以创建一个新的颜色drawable.我不确定这是否可行,但根据文档,它应该.它显然要求
public ColorDrawable(int color)
在API级别1中添加创建具有指定颜色的新ColorDrawable.
参数 color 要绘制的颜色.
所以,我的代码不起作用,因为我得到一个无效的int:"FF6666"错误.有任何想法吗?
int decode = Integer.decode("FF6666");
ColorDrawable colorDrawable = new ColorDrawable(decode);
Run Code Online (Sandbox Code Playgroud)