是否可以从值/颜色的Uri中将ColorFilter设置为imageView?
ImageView imageView;
String colorString = "colorBlack";
colorResourceNameURI = Uri.parse("android.resource://" + this.getPackageName() + "/values/colors/" + colorString.replace("\"", ""));
imageView.setColorFilter(colorResourceNameURI); //???
答案 0 :(得分:1)
您可以根据名称查找资源值;您不一定需要URI。参见this answer以获得部分解释:
int id = getResources().getIdentifier(colorString.replace("\"", ""), "color", getPackageName());
imageView.setColorFilter(getResources().getColor(id));