我试过这段代码:
LinearLayout someLayout=(LinearLayout)view.findViewById(R.id.someLayout);
someLayout.setBackgroundTintList(context.getResources().getColorStateList(Color.parseColor("#ff8800")));
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误:android.content.res.Resources$NotFoundException
我从外部源获取颜色十六进制,所以我无法将其嵌入colors.xml中.另外我想改变色调,而不是背景,所以setBackground不是一个选项.